Skip to content
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

I think the root page or index.html should be handled by runtime caching #32

Closed
lili21 opened this issue Jun 2, 2017 · 4 comments
Closed

Comments

@lili21
Copy link
Contributor

lili21 commented Jun 2, 2017

otherwise, user has to refresh twice to get the latest content. first for latest service worker, and second for latest index.html. right ?

so maybe the root page should be handle by runtime caching. only use the cache when user is offline.

@lili21 lili21 changed the title I think root page or index.html should be handled by runtime caching I think the root page or index.html should be handled by runtime caching Jun 2, 2017
@maxmilton
Copy link

What kind of changes are you making to your index.html? Typically with a SPA you leave it quite bare and instead use the framework to inject the content or change any meta tags etc.

@lili21
Copy link
Contributor Author

lili21 commented Nov 14, 2017

the filename of js and css ? everytime I change my code, the filename( hash ) will be changed, and the reference in index.html will be updated.

@dewdad
Copy link

dewdad commented Dec 31, 2017

Has any progress been made on this issue?

@jeffposnick
Copy link
Collaborator

Using a cache-first approach for navigation requests offers a meaningful performance benefits See "High-performance service worker loading" for more details.

The strategy that Vue PWA's service worker uses is effectively a stale-while-revalidate approach, with the "stale" content shown initially, and then refreshed in the background if there are updates detected in the service worker. The subsequent visit should result in the fresh HTML being displayed.

While you could get some offline-fallback benefits from using a different strategy for navigation requests, like a strategy which went to the network first and only displayed cached HTML when the network request failed, you lose the performance benefits.

It's unlikely that we're going to change that strategy for this template, but if you'd like an alternative approach, starting with the basic webpack template and then adding-in either a service worker library or just some handwritten service worker code to implement a network-first strategy is definitely an option. The Offline Cookbook is a great resource when you're writing your own service worker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants