-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime caching conflicts with precache #839
Comments
I just saw the
Based on this I suppose the behaviour I noticed is a bug. |
@jaspermdegroot this definitely sounds like a bug to me. Will take a look later today. Thanks for raising the bug. |
This sounds like something that went amiss when we changed the code to make registering the event listener for the The code from if (handleFetch) {
this._router.addFetchListener();
}
this._registerDefaultRoutes(ignoreUrlParametersMatching, directoryIndex); needs to be switched around so that the default routes are registered first. |
On further inspection, it looks like this might date back to #382, where we moved to a single I'm going to give some thought as to how to get this specific use case fixed without introducing breaking changes to the order in which we evaluate In the meantime, @jaspermdegroot, you could call workboxSW.router.setDefaultHandler(workbox.strategies.networkFirst()); to accomplish what you've intended. |
What a short term solution be to register a two fetch handlers - one for precaching and one for routing? We can't reliably add precaching to be the last route registered :( |
Yeah, that would probably be the best short-term solution. I can put something together for that in v2. See #845 about some changes we could make in v3. |
Thanks all for the quick response and for fixing it! @jeffposnick - Thanks for providing a temporary workaround. However, when setting the default handler I got an error saying the handler parameter is undefined instead of a function (I did change Anyway, I only precache the homepage so I will use something like this until next release:
|
Sorry, that example should have been: workboxSW.router.setDefaultHandler({handler: workbox.strategies.networkFirst()}); (We're in the process of moving from objects with named properties to positional properties for this sort of thing in v3, and I got confused.) |
When runtime caching is applied to a page that is precached, that page won't work offline anymore.
This affects the workbox-sw library. Tested on Chrome 61 on MacOS.
The Progressive Web AMP codelab at https://codelabs.developers.google.com/codelabs/amp-pwa-workbox/ illustrates the issue. The homepage is precached, but if you navigate from any of the articles to the homepage while offline the homepage won't be displayed and the console shows the following error:
If you visit the homepage after the SW is installed and before going offline, so the page is added to the runtime cache, the page will be displayed.
I also included a more basic test case without app shell:
workbox-issue.zip
Is this indeed a bug or is this expected behaviour and is it up to the developer to keep precached files in mind when adding routes?
The text was updated successfully, but these errors were encountered: