-
Notifications
You must be signed in to change notification settings - Fork 331
toolbox.precache should not cache invalid files #75
Comments
The background on the current behavior is covered in this issue from the old repo: wibblymat/shed#5 The current configuration is at https://github.com/GoogleChrome/sw-toolbox/blob/master/lib/options.js#L39 and developers could technically override the defaults using whatever My vote is to keep the current behavior, but I can definitely see the justification for the other side. |
That bug is in reference to networkFirst behaviour, not the precache behaviour. The obvious major downside of this is the progressive web app story where you may need and rely on a file that doesn't get cached. In that scenario I'd expect the sw to fail to install. Appreciate it can be overriden but I don't think this default behaviour is good or expected. cc @jakearchibald because I know there was discussion around behaviour or cache.addAll and caching 404s. |
Overall I think I'm in favour of being stricter in the precache. A successful install should mean that the app is ready for offline. However, playing Devil's Advocate, here are some cases where the current behaviour is possibly better:
|
404Caching 404 pages is an interesting use case, I'd see two options:
This could look something like:
Nice thing with a callback function is that the developer is given a lot of control if they want it. Failing new SWFew things that weren't obvious with this:
My main thoughts were to provide an option that basically says if the install fails fallback to network. I'm thinking of an indexdb value that indicates that a new toolbox installed failed. This would allow all of the above options. A different consideration is that if developers are concerned with this behaviour, they could just return true in precache callback and then they'll always get the latest SW. Not ideal, but for some it may be an ok option. |
General discussion:
|
If Here is PR to fix that: dominiccooney/cache-polyfill#19 |
@NekR thanks for chiming in. The problem isn't around addAll (although I'm aware that it's behaviour will affect this). It's a discussion of the regex used for caching as @jeffposnick mentioned: https://github.com/GoogleChrome/sw-toolbox/blob/master/lib/options.js#L39 |
@gauntface sorry, I thought it's about |
For us, adding 404s was weird unexpected behavior even as a developer. |
At the moment toolbox.precache will cache a 404 response.
My initial assumption this in unexpected default behavior (and not something I think would be desirable in any situation).
Would allowing 20x status be a better option?
The concern this raises is what is the behavior when a 404 is encountered? I would expect the service worker install to fail.
The text was updated successfully, but these errors were encountered: