Skip to content

fix: cache-bust style.css per build (deploys picked up immediately)#76

Merged
p4gs merged 1 commit into
mainfrom
fix/css-cache-bust
Jun 2, 2026
Merged

fix: cache-bust style.css per build (deploys picked up immediately)#76
p4gs merged 1 commit into
mainfrom
fix/css-cache-bust

Conversation

@p4gs

@p4gs p4gs commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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-modified matched the merge, new markers present, old gone), but the stylesheet <link> carried no version string and is sent with cache-control: max-age=600. So browsers reuse the cached style.css for 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.time is 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.

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.
@p4gs p4gs merged commit 5a6c375 into main Jun 2, 2026
5 checks passed
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.

1 participant