What’s the difference between using the Service Worker Cache API and regular browser cache?

The primary difference is control. Browser cache is driven off Cache-Control headers, which is good, until its not. There are all sorts of strategies to manage how network addressable resources are cached; private, public; time to live, etc. With service worker caching you can programmatically control how those assets are persisted. But that means the … Read more

navigator.serviceWorker is never ready

The problem was that the service-worker.js file was stored in an assets sub-directory. Don’t do that: store the service-worker.js in the root of your app (or higher). That way your app can access the service-worker. See HTML5Rocks article — One subtlety with the register method is the location of the service worker file. You’ll notice … Read more

Structuring a TypeScript project with workers

Many thanks to Mattias Buelens who pointed me in the right direction. Here’s a working example. The project structure is: dist src generic-tsconfig.json main (typescript files) tsconfig.json dedicated-worker (typescript files) tsconfig.json service-worker (typescript files) tsconfig.json src/generic-tsconfig.json This contains the config common to each project: { “compilerOptions”: { “target”: “esnext”, “module”: “esnext”, “strict”: true, “moduleResolution”: “node”, … Read more

Why use a service worker for caching when browser cache handles the caching?

Service Workers give you complete control over network requests. You can return anything you want for the fetch event, it does not need to be the past or current contents of that particular file. However, if the HTTP cache handles your needs, you are under no obligation to use Service Workers. They are also used … Read more

Service worker JavaScript update frequency (every 24 hours?)

Note: As of Firefox 57, and Chrome 68, as well as the versions of Safari and Edge that support service workers, the default behavior has changed to account for the updated service worker specification. In those browsers, HTTP cache directives will, by default, be ignored when checking the service worker script for updates. The description … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)