Service Workers essentially act as proxy servers that sit between web applications.
My concern: Is ServiceWorker also support for offline forms? - If so then my other list of concerns are:
First off, service workers could potentially do a lot of things. They have access to IndexedDB, for instance, so there's always the possibility of saving and loading arbitrary data, from the context of either a controlled page or a service worker.
But none of that will happen automatically by virtue of having an service worker registered—a service worker will, by default, do absolutely nothing. It's only when you write code in the service worker to hook into different events (install
, fetch
, message
, etc.) that things get interesting.
Hypothetically, if you were to write code in a service worker that cached an HTTP response for an HTML resource and then responded to fetch
events for the request's URL with that cached response, then the browser would get back and render the same HTML as it would if the response had come from the network. There wouldn't be any special "form state" that gets cached along with the HTML response body.
If, for some reason, you did want to save "form state" so that users who leave a page with a form could return and continue editing it, you'd have to do that independently of the caches
object that's exposed to the service worker. (caches
requires that you use Request
objects as keys and stores Response
objects as values.)
So you could potentially do it using IndexedDB
, or you could do it using localStorage
, or really anything else. It's independent of the service worker, and the particular privacy/security considerations are up to the implementer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With