From a339ea93b164727ff09db36d6fd61239ea30557e Mon Sep 17 00:00:00 2001 From: jzzliu Date: Sat, 7 Nov 2026 21:29:43 -0700 Subject: [PATCH] Version the stylesheet URL by content hash at image build A CDN in front of the site caches /style.css for hours, so a redeploy served new HTML with the old stylesheet. The Dockerfile now rewrites the link to style.css?v= in the built image (source stays unversioned) and fails the build if the rewrite does not apply. --- Dockerfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Dockerfile b/Dockerfile index 14bff92..79fc7dc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,9 @@ FROM caddy:2 COPY Caddyfile /etc/caddy/Caddyfile COPY dist/ /srv/fieldwork/ + +# A CDN in front of the site may cache /style.css for hours. Version its URL by content hash +# so a changed stylesheet is always fetched fresh. The build fails if the rewrite did not apply. +RUN h=$(md5sum /srv/fieldwork/style.css | cut -c1-10) \ + && sed -i "s|href=\"style.css\"|href=\"style.css?v=${h}\"|" /srv/fieldwork/index.html \ + && grep -q "style.css?v=${h}" /srv/fieldwork/index.html