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

Updated vaadin-flow-bundle.html is not loaded in the browser #3501

Closed
Artur- opened this issue Feb 7, 2018 · 5 comments · Fixed by #3918
Closed

Updated vaadin-flow-bundle.html is not loaded in the browser #3501

Artur- opened this issue Feb 7, 2018 · 5 comments · Fixed by #3918

Comments

@Artur-
Copy link
Member

Artur- commented Feb 7, 2018

When updating a production build, the browser does not immediately load the new bundle so you end up with an old version of the app. The cache headers say that the browser should cache the file for an hour.

Preferrably, this should be solved as:

  1. Add the hash of the vaadin-flow-bundle.html file contents to the name of the file
  2. Set cache headers for the bundle so that it is cached forever

That would mean no "check for new version" overhead and new versions immediately taken into use.

A simpler first version would be to just add a timestamp to the filename whenever it is created

@Legioth
Copy link
Member

Legioth commented Apr 12, 2018

The easiest way of doing this is probably to somehow make the production building done by the Maven plugin rename the produced files (based on what's listed in vaadin-flow-bundle-manifest.json) and then also update the manifest to point to the rewritten files.

There might also be a feature in Polymer CLI that automatically does the renaming without us having to do anything else than enable that feature.

@Legioth
Copy link
Member

Legioth commented Apr 12, 2018

As an additional enhancement, we could also update the logic in StaticFileServer to add strong cache headers when serving any filename that seems to contain a hash at the end (i.e. ends with n hex characters).

@pleku
Copy link
Contributor

pleku commented Apr 12, 2018

The hashing can happen on the polymer/gulp side or in the maven plugin with java. Some npm libraries that might do the job: https://www.npmjs.com/search?q=hash

@web-padawan
Copy link
Member

web-padawan commented Apr 12, 2018

I've used gulp-rev-all to generate hash fingerprints and rename files, then another plugin to rewrite any occurrences. See my comment here with the example gulp snippet. Consider also taking a look at gulp-polymer-build-utils which is a set of gulp tasks containing the similar one.

@pleku
Copy link
Contributor

pleku commented Apr 13, 2018

Before starting, make sure to see that there is no PRs open related to this, eg. @Artur- refactoring everything.

Also take into account that there is the ES5 file to consider, which might have changed even though ES6 file has not.

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

Successfully merging a pull request may close this issue.

6 participants