Service workers allow website authors to intercept all network requests to their websites

Talk about internet security, computer security, personal security, your social security number...
Post Reply
morganism
Senior Member
Posts: 120
Joined: Tue Nov 26, 2013 9:44 pm

Service workers allow website authors to intercept all network requests to their websites

Post by morganism » Sat Jul 25, 2020 6:27 pm

Service workers allow website authors to intercept all network requests to their websites

https://www.theguardian.com/info/develo ... uardiancom

https://developers.google.com/web/funda ... ce-workers

"You must be running a browser that supports the Service Worker and fetch APIs. At the time of writing only Chrome (mobile and desktop) supports both of APIs, but support is coming in Firefox very soon (currently in the nightly build), and all browsers except Safari have shown enthusiasm. Furthermore, service workers can only be registered for websites served over HTTPS, which theguardian.com has started to move towards. Thus, we can only offer the offline experience for HTTPS sections of the website."

"We can instruct browsers to register our service worker as soon as the user arrives on the page with some simple JavaScript. Support for service workers is currently sparse, so we need to use feature detection to avoid any errors.

if (navigator.serviceWorker) {
navigator.serviceWorker.register('/service-worker.js');
}

As part of the service worker’s install event, we can use the new cache API to cache the various moving parts of our website, such as HTML, CSS, and JavaScript:"
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Firefox/68.0

Post Reply