fix(server): add Cache-Control headers to static assets#27934
Open
BYK wants to merge 1 commit into
Open
Conversation
Hashed assets (Vite content-hashed filenames) get immutable/1yr cache. HTML gets no-cache to always revalidate for fresh asset references. Other static files (favicons, manifest) get 1hr cache.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: One potentially related PR found: PR #27936: fix(app): add service worker for cache-first static asset loading Why it might be related: This PR also addresses static asset caching strategy. While PR #27934 focuses on Cache-Control headers at the server level, PR #27936 appears to implement client-side caching via service worker. These could be complementary approaches or potentially address overlapping concerns in the caching strategy. Worth reviewing to ensure they work together cohesively. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #27931
Type of change
What does this PR do?
Adds
Cache-Controlheaders to the embedded web UI asset responses inserver/shared/ui.ts:index-abc123.js):public, max-age=31536000, immutable— these filenames change when content changes, so they can be cached indefinitely.no-cache— always revalidate to pick up new asset references.public, max-age=3600— reasonable 1hr cache.A regex detects Vite's content-hash pattern (
-or.followed by 8+ hex chars before the extension).How did you verify your code works?
Tested locally by checking response headers on static assets served by the embedded web UI. Verified hashed assets get
immutable, HTML getsno-cache, and other files get 1hr cache.Screenshots / recordings
N/A — response header change.
Checklist