Skip to content

Commit ac23021

Browse files
MrSpamer Botclaude
andcommitted
feat: auto cache-bust CSS/JS with content hash on deploy
Replace manual ?v=X versioning with automatic MD5 content hash so browsers always reload after changes without hard refresh. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a95069d commit ac23021

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

.github/workflows/gh-pages.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ jobs:
1111
steps:
1212
- uses: actions/checkout@v4
1313

14+
- name: Cache-bust CSS and JS with content hash
15+
run: |
16+
CSS_HASH=$(md5sum html/style.css | cut -c1-8)
17+
JS_HASH=$(md5sum html/main.js | cut -c1-8)
18+
find html -name '*.html' -exec sed -i "s|style\.css?v=[^\"]*|style.css?v=${CSS_HASH}|g" {} +
19+
find html -name '*.html' -exec sed -i "s|main\.js|main.js?v=${JS_HASH}|g" {} +
20+
1421
- name: Deploy to GH Pages
1522
uses: peaceiris/actions-gh-pages@v3
1623
with:

0 commit comments

Comments
 (0)