Skip to content

fix(caddy): add cache-control headers for static assets, service worker, and index.html#609

Draft
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:fix/caddy-cache-headers
Draft

fix(caddy): add cache-control headers for static assets, service worker, and index.html#609
Just-Insane wants to merge 2 commits intoSableClient:devfrom
Just-Insane:fix/caddy-cache-headers

Conversation

@Just-Insane
Copy link
Copy Markdown
Contributor

Related to closed PR #548 (fix/media-error-handling), which was split into smaller focused PRs.

Description

Without explicit Cache-Control headers, browsers apply heuristic caching to all responses — including sw.js and index.html. This causes stale service workers and stale app shells to persist after a deploy. Three header rules added to the Caddyfile:

  • /assets/*public, max-age=31536000, immutable: content-hashed filenames change on every build, so these are safe to cache permanently.
  • /sw.jsno-cache: must always be revalidated so the browser picks up SW updates promptly.
  • /index.htmlno-cache: must always be revalidated so the browser gets the latest asset hashes on load.

Fixes #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

AI disclosure:

  • Partially AI assisted (clarify which code was AI assisted and briefly explain what it does).
  • Fully AI generated (explain what all the generated code does in moderate detail).

The cache header rules were partially AI assisted. I verified the immutable directive is appropriate for content-hashed assets and that no-cache (revalidate-always, not no-store) is correct for sw.js and index.html.

@Just-Insane Just-Insane requested review from 7w1 and hazre as code owners March 31, 2026 18:43
@Just-Insane Just-Insane marked this pull request as draft March 31, 2026 20:13
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