question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service Worker not busting cache.

See original GitHub issue

Hello, I’ve got a weird issue.

In devtools, I have cache disabled.

When I hit ctrl+r, it still lads a cached old file with an error.

When I hit shift+ctrl+r, no problem, and the new file is used and error is gone.

Despite Chrome devtools having cache disabled, that has no effect. Only pressing shift+ctrl+r loads the non-cached version, while pressing ctrl+r always loads the older cached file.

Seems like this has to do with service worker. How do I ensure that caching works properly with the service worker, to eliminate that as possible source of the problem?

Note, I’ve loaded the production build with a static server a couple times to test it, not sure if that’s somehow messing up with the service worker while I’m in dev mode.

I’m experiencing this in dev mode.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:21

github_iconTop GitHub Comments

5reactions
u12206050commented, May 14, 2019

@xerosanyam here is a crude way: Create a single javascript file that you exclude from cache and then check for that file say every 10seconds from within your app somewhere. Once the file is not found (due to the suffix of it changing, you can force reload the entire page using window.location.reload(true)

3reactions
u12206050commented, May 16, 2019

That is because it currently gets generated on every build. You need to update the vue.config.js file as I mentioned above, with

  pwa: {
    workboxPluginMode: 'InjectManifest',
    workboxOptions: {
      swSrc: 'service-worker.js',
    },
  }

This tells the pwa plugin that you supply your own service-worker.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Service worker caching and HTTP caching - web.dev
For example, a user may purge the cache by manually cleaning up from a browser's settings UI, or triggering a hard-reload on a...
Read more >
Service Worker Cache Busting | Jun711 blog
If you have already deployed your app but forgot to set Cache-Control header of your service-worker.js file to be no cache, you can...
Read more >
angular - Problems cache busting serviceworker index.html file
I'm using Google's SW Precache to generate the serviceworker for an Angular (currently v.4) app hosted on firebase.
Read more >
Service Worker Caching and HTTP Caching
Control Service Worker Cache ... A Service Worker intercepts HTTP requests with Event Listeners (E.g. fetch event). The logic of caching is ...
Read more >
Strategies for Service Worker Caching for Progressive Web ...
You need to wait out the cache expiry time (usually ~24h if no http cache header is set) to invalidate the service-worker.js file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found