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

[#439] Append a hash to minified file names. #584

Merged
merged 1 commit into from
May 4, 2022
Merged

Conversation

jaragunde
Copy link
Member

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.

Fixes #439.

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 jaragunde requested a review from anarute May 2, 2022 15:35
Copy link
Member

@anarute anarute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this, I never found the time to do it.

@jaragunde
Copy link
Member Author

Same as I, but I found an article about a solution that looked straightforward to implement and I gave it a try. It wasn't so easy and I got in trouble with regexps, but I think it works in the end. We need to be careful when deploying it.

@jaragunde jaragunde merged commit 98e81bf into main May 4, 2022
@jaragunde jaragunde deleted the i439-cache-busting branch May 4, 2022 08:09
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 this pull request may close these issues.

Force browser to clear cache after upgrade
2 participants