Skip to content

fix: content-hash static assets so CSS updates aren't served stale#49

Merged
dmccoystephenson merged 1 commit into
mainfrom
fix/static-asset-cache-busting
Jun 7, 2026
Merged

fix: content-hash static assets so CSS updates aren't served stale#49
dmccoystephenson merged 1 commit into
mainfrom
fix/static-asset-cache-busting

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Fixes the reported bug where the password field rendered unstyled (white/small) until you pressed "Show" or hard-refreshed. The deployed CSS was correct, but the stylesheet was linked at the fixed path /css/style.css with no cache-busting — so browsers kept serving a stale cached copy from before the password-styling fix. Pressing "Show" flips the input to type="text", which the old cached rule happened to match, masking the problem.

Fix

Enables Spring's content-based static-resource versioning (spring.web.resources.chain.strategy.content). Thymeleaf @{/css/style.css} links now resolve to /css/style-<md5>.css; when the file changes, the hash and URL change, and browsers fetch the new file immediately instead of reusing a cached one. This prevents the stale-asset problem for all future CSS/JS changes, not just this one.

Test

  • New StaticAssetVersioningTest (@SpringBootTest + MockMvc) renders /login and asserts the stylesheet is linked via its content-hashed URL, not the bare /css/style.css.
  • Full web-client suite green (9 tests).

Note

Deploying this changes the stylesheet URL, so it also resolves the stale view for anyone currently affected — no hard refresh needed once it's live.

🤖 Generated with Claude Code

…hed stale

The stylesheet was linked at the fixed URL /css/style.css, so after a deploy a
player's browser kept serving its cached copy of the old CSS. That's why the
password-field styling fix didn't appear until a hard refresh — the field only
looked right after pressing "Show" because the stale rule matched type="text".
Any future CSS change would hit the same wall.

This enables Spring's content-based resource versioning, so Thymeleaf @{} links
resolve to /css/style-<md5>.css; when the file changes the hash changes, the URL
changes, and the browser fetches the new file immediately. A @SpringBootTest
asserts the rendered login page links the versioned URL rather than the bare
path, guarding against regressions.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@dmccoystephenson dmccoystephenson merged commit fe20afb into main Jun 7, 2026
2 checks passed
@dmccoystephenson dmccoystephenson deleted the fix/static-asset-cache-busting branch June 7, 2026 23:05
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