-
Notifications
You must be signed in to change notification settings - Fork 801
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
Support for navigationPreload in workbox-build #1981
Conversation
Thanks for the contribution! I'll give it a review soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a ton for this work! All of the current code looks good.
After thinking about navigation preload a little more bit more, one thing that might make sense is to try to steer developers in the direction of actually using the preloaded response, instead of setting navigationPreload: true
but then not doing anything with the resulting response. (I'll do this in a separate PR against the documentation regardless.)
If you're using GenerateSW
, with navigationPreload: true
, then my assumption is that you almost always should use runtimeCaching
to set up a route that will use that preloaded response.
This doesn't hold 100% of the time, because maybe you're using importScripts
and taking advantage of the preloaded response inside of that. But for that scenario, you don't have to set navigationPreload: true
at all, and you could just call workbox.navigationPreload.enable()
inside your imported script.
If you set navigationPreload
to true
but don't use runtimeCaching
, that's something that we could prevent via joi
validation rules. )Unfortunately, we can't actually validate that runtimeCaching
ends up using the preloaded responses, just that it's being set to something.)
@merrywhether, since you're the one who's actually planning on using this, does making runtimeCaching
required whenever navigationPreload
is true
match your use case?
@jeffposnick We're actually starting slow with service workers and testing them out only on images (for which we have defined |
So if you enable navigation preload but don't actually make use of the response in a
There's no implicit usage of the preloaded responses when you don't respond to the You need to do something like https://developers.google.com/web/tools/workbox/modules/workbox-navigation-preload#basic_usage, i.e. at the minimum, set up a In the
It sounds like using |
@jeffposnick Thanks for pointers, makes the PR effort even more useful to us! I went ahead and updated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Your contribution is really appreciated.
R: @jeffposnick @philipwalton
Fixes #1915
Adds
navigationPreload
config property (defaulting to false) toworkbox-build
'sgenerateSW
andgenerateSWString
modes, which would also expose it to the wrappers likeworkbox-cli
andworkbox-webpack-plugin
.gulp lint test
passes locally. I've been added to my company's CCLA group.