-
Notifications
You must be signed in to change notification settings - Fork 819
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
sw-precaching and Routing #136
Comments
How about this? (I think it's pretty similar to what was in a design doc somewhere.) const precacheManager = new goog.precaching.PrecacheManager();
// Do stuff with precacheManager to set up the manifest, etc....
const router = new goog.routing.Router();
// This would create a Route that knew exactly which URLs to match and would use a
// cache-first strategy as the handler.
const precacheRoute = precacheManager.createRoute();
router.registerRoute({route: precacheRoute});
// Register any additional runtime routes at this point. That's the lower-level picture, of course. Maybe there's an opportunity to have |
That sounds like a good mix of giving the developer choice when using the module directly and sw-lib can super easily make this so. Will make a PR for this to see what you think of an approach. |
Here's another wrinkle: Routing navigation requests to the cached App Shell is an important use case, so we should address it somehow:
If we go with 1., it would probably fall to @gauntface as part of the related work tracked in this issue. If we go with 2., I'll file a separate issue and assign it to myself. |
Thinking on this a little more and struggling to picture the best way to do it with the current API. Discussing the navigateFallback in relation to precache management is a bit of a wake up call that this might not be the best approach. An alternative approach to the above is to just not include routing within precaching and instead expose the required details so a Basically we'd up with something along these lines (Ignoring the URL parsing / dance to make them actually the same format):
This approach could be abstracted to a separate Route that can wrap everything up nicely (useful for consumers of the small libraries). With or without a "PrecacheRoute", sw-lib can abstract this away from consumers of the higher level library. This approach would then also leave the navigateFallback to a seperate discussion as to how it's handled by the |
Hiding magic and papering over the low-level libraries details—like the cache name and list of resources that We could move the |
coolio and 👍 to moving navigateFallback to a seperate issue to track it. |
sw-precaching at the moment ONLY caches assets, it doesn't define any routes.
There are a few things to consider:
Solutions:
The text was updated successfully, but these errors were encountered: