fix: cache-bust style.css per build (deploys picked up immediately)#76
Merged
Conversation
The stylesheet <link> had no version string, so browsers cached it for
max-age=600 (10 min) — after a deploy users kept seeing the old CSS until
the cache expired. Append ?v={{ site.time | date '%s' }} (build timestamp)
so every deploy yields a fresh URL and the new CSS loads immediately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After merging a CSS change and waiting for Actions to finish, the live site kept showing the old styling. Verified the cause: the origin was serving the new CSS (
last-modifiedmatched the merge, new markers present, old gone), but the stylesheet<link>carried no version string and is sent withcache-control: max-age=600. So browsers reuse the cachedstyle.cssfor up to 10 minutes after every deploy.Fix
Append a per-build version to the stylesheet URL:
href="{{ '/assets/css/style.css' | relative_url }}?v={{ site.time | date: '%s' }}"site.timeis the Jekyll build timestamp, so every deploy produces a fresh URL (style.css?v=<ts>) and browsers fetch the new CSS immediately instead of waiting out the cache.Verification
Build clean (exit 0); compiled
<link>carries?v=<timestamp>on the home page and guide pages (layout-wide). One-line change in_layouts/default.html.