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

Force browser to clear cache after upgrade #439

Closed
jaragunde opened this issue Jan 15, 2019 · 2 comments · Fixed by #584
Closed

Force browser to clear cache after upgrade #439

jaragunde opened this issue Jan 15, 2019 · 2 comments · Fixed by #584

Comments

@jaragunde
Copy link
Member

When we upgrade (or hotfix) the server, users often have trouble with cached files. There are methods to force that from the server, like appending a GET parameter to .js and .css requests with the version number, like: ext.min.js?v=2.18.

The method is described here: https://stackoverflow.com/a/1922924

@jaragunde
Copy link
Member Author

jaragunde commented May 2, 2022

Apparently, a variation of this technique is still generally used, it's called "cache busting": https://javascript.plainenglish.io/what-is-cache-busting-55366b3ac022

We could integrate this in our minification process, naming the minified files filename.[hash].js.

jaragunde added a commit that referenced this issue May 2, 2022
This will enforce browsers to retrieve again the file when the hash
changes, making sure users don't use old versions of the JS code.

The minify script is changed in several ways, in addition to
calculating and appending the hash to the file name:

* To revert previous minification, we now use git reset --hard. It's
  dangerous but prevents the regexp logic from getting too wild.

* We now loop through the php files for every js file, making the
  script much less efficient. Again, this is done to simplify regexp
  logic.

* Explicitly delete source map files from previous minification, to
  prevent maps with different hashes to pile up.
jaragunde added a commit that referenced this issue May 4, 2022
This will enforce browsers to retrieve again the file when the hash
changes, making sure users don't use old versions of the JS code.

The minify script is changed in several ways, in addition to
calculating and appending the hash to the file name:

* To revert previous minification, we now use git reset --hard. It's
  dangerous but prevents the regexp logic from getting too wild.

* We now loop through the php files for every js file, making the
  script much less efficient. Again, this is done to simplify regexp
  logic.

* Explicitly delete source map files from previous minification, to
  prevent maps with different hashes to pile up.
jaragunde added a commit that referenced this issue May 9, 2022
We also tune a bit the `find` commands, to reduce the search scope.
anarute pushed a commit that referenced this issue May 23, 2022
We also tune a bit the `find` commands, to reduce the search scope.
@jaragunde
Copy link
Member Author

Fixed with these commits, reviewed in PR #584 and #586:

commit c860dc1ff8bcd383c036365bea40e3fbf8f85b57 
Author: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Date:   Mon May 9 10:23:50 2022 +0200

    [#439] Properly minify holidayManagement.js.
    
    We also tune a bit the `find` commands, to reduce the search scope.

commit 98e81bfd974b0fec21fed43a589128f788b86086
Author: Jacobo Aragunde Pérez <jaragunde@igalia.com>
Date:   Mon May 2 13:01:09 2022 +0200

    [#439] Append a hash to minified file names.
    
    This will enforce browsers to retrieve again the file when the hash
    changes, making sure users don't use old versions of the JS code.
    
    The minify script is changed in several ways, in addition to
    calculating and appending the hash to the file name:
    
    * To revert previous minification, we now use git reset --hard. It's
      dangerous but prevents the regexp logic from getting too wild.
    
    * We now loop through the php files for every js file, making the
      script much less efficient. Again, this is done to simplify regexp
      logic.
    
    * Explicitly delete source map files from previous minification, to
      prevent maps with different hashes to pile up.

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.

1 participant