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

Version bundle.js & style.css #23

Closed
3 tasks
lukeed opened this issue May 20, 2017 · 13 comments · Fixed by #172
Closed
3 tasks

Version bundle.js & style.css #23

lukeed opened this issue May 20, 2017 · 13 comments · Fixed by #172

Comments

@lukeed
Copy link
Member

lukeed commented May 20, 2017

I would call this "mild priority" right now, simply because, as is, bundle.js is the majority of the application weight//network transfer. It's set for a maximum of 1 hour, which means that users will need to redownload an entire application, regardless of any changes it may or may not have had. Plus, this kind of impedes the function of offline/sw-precache.

Also, in the rare event that my app goes from v1 to v2 within the hour that User has cached my bundle, their next request would grab all the v2 chunks & sw.js, which still points to non-versioned bundle.js, which results in User working with a mismatched set of assets... the majority of which (in bundle) is now outdated.

If we're on the same page here, we'd need to:

  • Version bundle.js, like everything else
  • Update server headers; would up it to 1YR
  • Replace the HTML bundle.js link per-build; handled by html-webpack-plugin

This all applies to style.css as well: same tasks & reasoning.

@developit
Copy link
Member

this would probably break the serviceworker setup since the html has to change in order to update the bundle url, right?

@lukeed
Copy link
Member Author

lukeed commented May 20, 2017

I'm not sure what you mean. The html would be different per build, and would be cached alongside the new build assets too. You'd be looking at fully immutable builds, from version to version.

@developit
Copy link
Member

Can't do immutable HTML since that's the entry point - its url has to be /. The issue comes when you're on a page and the SW updates, and then have to reload to get the newest version. Maybe I'm thinking of this wrong?

@dstaley
Copy link

dstaley commented May 20, 2017

Correct me if I'm wrong, but if you're not fingerprinting the assets, can't a user find themselves in a situation where their browser has evicted bundle.js from the cache, but not style.css, resulting in a newer version of bundle.js being styled with the previous version of style.css?

@lukeed
Copy link
Member Author

lukeed commented May 20, 2017

Sorry, "immutable" as in all assets. Only the index.html and sw.js filenames will be the same, but their contents always point to new files.

@lukeed
Copy link
Member Author

lukeed commented May 20, 2017

@dstaley right, that's what I'm trying to voice. When assets arent uniformly cached and versioned, you give yourself a window of being caught in between states.

@developit
Copy link
Member

html-webpack-plugin has a hash option that appends the compilation hash to assets, which might work for this:
https://github.com/jantimon/html-webpack-plugin#configuration

@lukeed
Copy link
Member Author

lukeed commented May 20, 2017

Correct. Would be the same process and tasks regardless of hash or filename addition

I've been doing this for my projects and preact-starter, haven't run into any issues yet.

@AvraamMavridis
Copy link

What's the status of this? It would be great if there is an option in the cli to append hash on the bundle.

@developit
Copy link
Member

I think the hash-in-querystring approach is doable in the short term.

@thangngoc89
Copy link
Collaborator

I have a fork that added hashing the bundle. I'll send a PR

@lukeed
Copy link
Member Author

lukeed commented Jun 11, 2017

@developit What's your hesitation to adding filename-hashes? I'm not sure, but I don't think that the querystring approach is compatible with even all the servers we offer ootb. Certainly more error-prone in userland with user-setup-servers... perhaps.

@thangngoc89
Copy link
Collaborator

@lukeed It's true. I'm having a hard time fighting with nginx and querystring caching

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

Successfully merging a pull request may close this issue.

5 participants