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

Bust cache for CSS and JS on every build #3097

Merged
merged 1 commit into from
Sep 5, 2023
Merged

Conversation

mudge
Copy link
Contributor

@mudge mudge commented Sep 5, 2023

GitHub: #2991

To prevent stale versions of our stylesheets and JavaScript from being served after a deploy, ensure their URL is unique for each build by appending the time of the build (as seconds since the epoch) in a query string.

This means we will bust the cache even if our CSS and JS don't change (as the query string changes on every build rather than being a function of the contents of the relevant file) but this errs on the side of caution and keeps the implementation very simple compared to introducing an asset pipeline.

We only add the cache busting query string to files we change as opposed to vendored JavaScript (jQuery, etc.) as they shouldn't change without also updating their filename.

GitHub: #2991

To prevent stale versions of our stylesheets and JavaScript from being
served after a deploy, ensure their URL is unique for each build by
appending the time of the build (as seconds since the epoch) in a query
string.

This means we will bust the cache even if our CSS and JS don't change
(as the query string changes on every build rather than being a function
of the contents of the relevant file) but this errs on the side of
caution and keeps the implementation very simple compared to introducing
an asset pipeline.

We only add the cache busting query string to files we change as opposed
to vendored JavaScript (jQuery, etc.) as they shouldn't change without
also updating their filename.
@aallan aallan linked an issue Sep 5, 2023 that may be closed by this pull request
@aallan aallan added enhancement toolchain This is an infrastructure/toolchain issue labels Sep 5, 2023
@aallan aallan merged commit e40f720 into develop Sep 5, 2023
1 check passed
@aallan aallan deleted the bust-asset-cache branch September 5, 2023 09:59
@lurch
Copy link
Contributor

lurch commented Sep 5, 2023

Nice 👍

mudge added a commit that referenced this pull request Oct 4, 2023
Following on from the work in
#3097, ensure we bust
the cache for boxes.css too which was missed in the first pass as it
isn't included on every page.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement toolchain This is an infrastructure/toolchain issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add cache-busting fingerprints
3 participants