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.

Bad SW Caching of HTML

See original GitHub issue

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes. Pretty sure this is a configuration issue

Which terms did you search for in User Guide?

Cache, Service Worker, SWPrecacheWebpackPlugin, Precache

Environment

Mac OS, Node 8.10.x

Steps to Reproduce

  1. Include a second .html file in the /public directory (I will use sample.html for this report)
  2. Build the Project
  3. Load the site from the index.html
  4. Attempt to load sample.html, such as in an <iframe>

Expected Behavior

The sample.html should be served

Actual Behavior

The index.html is loaded by the service worker

I also want to note that sample.html is not included in the asset-manifest.json, which seems like it might be an issue. sample.html is also not included in the SWPrecache static cache files (the ones that get hashed and precached inside the service-worker.js output file).

Notes

I have ejected. I am prepared to alter my config in any way necessary to get this working.

I am asking here instead of SWPrecache because the amount of “create-react-app” configuration will make it much harder for them to diagnose.

I have tried adding the folliwing to the precache config

mergeStaticsConfig: true,
staticFileGlobs: ['public/sample.html'],
stripPrefix: 'public/',

...
// and in runtimeCaching
{
      urlPattern: '/sample.html',
      handler: 'networkOnly'
},

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
r3wtcommented, Oct 2, 2018

idiots

0reactions
r3wtcommented, Oct 2, 2018

We did remove the service worker entirely. It’ll no longer be present in v2.

how to upgrade to v2 with already ejected app?

Read more comments on GitHub >

github_iconTop Results From Across the Web

index.html cached in a bad state when service worker updates ...
I don't know if this is a bug of workbox not updating the index.html in cache despite the new revision number, or somehow...
Read more >
Angular service worker and index.html caching - Stack Overflow
In a normal HTTP cache, a hard refresh or cache expiration limits the negative effects of caching an invalid file. A service worker...
Read more >
A guide to Service Workers - pitfalls and best practices
Avoid caching bad responses by properly handling them in fetch. A fetch promise always returns a response object for the given request, which ......
Read more >
Caching best practices & max-age gotchas - JakeArchibald.com
I strongly advise against caching the service worker using pattern 1. Problem is, your HTML or JS contains the navigator.serviceWorker call. You ...
Read more >
Using Service Workers - Web APIs | MDN
A service worker functions like a proxy server, allowing you to modify requests and responses replacing them with items from its own cache....
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