perf(dashboard): immutable cache headers on hashed assets (#28543 salvage) - #77693
Merged
kshitijk4poor merged 1 commit intoAug 3, 2026
Merged
Conversation
…aders Every hashed bundle chunk under /assets/ was served with no caching directives, so each dashboard load re-fetched (or at best revalidated) every JS/CSS chunk. Those filenames carry a Vite content hash — the bytes behind a given URL can never change; a rebuild mints new filenames referenced by a freshly served index.html. Mark them Cache-Control: public, max-age=31536000, immutable: - the /assets StaticFiles mount, via a subclass that stamps the header on 200s only (404s stay uncached — a rebuild can create the file), - serve_css, preserving its X-Forwarded-Prefix url() rewrites for /fonts/, /fonts-terminal/, /ds-assets/, /assets/. index.html keeps no-store, no-cache, must-revalidate — it is the mutable entry point that binds users to the current hashes. The original PR also added hand-rolled per-request gzip compression of asset responses; that part is deliberately dropped. This server is a localhost-default dashboard backend: compressing every response on the CPU to save loopback bandwidth is a pessimization, and callers that front it with a real proxy already get compression there. Salvaged from PR NousResearch#28543 (idea by @sea-monsters; gzip groups dropped as described above). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
kshitijk4poor
enabled auto-merge (rebase)
August 3, 2026 13:00
6 tasks
|
Code Review: #77693 Verdict: Approve Test: additional coverage. LGTM - Reviewed diff. Changes are sound. |
sea-monsters
pushed a commit
to sea-monsters/hermes-agent
that referenced
this pull request
Aug 4, 2026
…#77693 salvage Upstream reviewed our PR NousResearch#28543 and landed NousResearch#77693 as an extract-salvage: adopt the immutable cache headers on hashed assets, drop the hand-rolled gzip (per-request level-6 compression is a net CPU pessimization on the default 127.0.0.1 bind with zero transfer win). This commit follows that upstream decision: - serve_css: return CSS with _IMMUTABLE_ASSET_CACHE_CONTROL (no gzip) - Replace _OptimizedStaticFiles with upstream _ImmutableAssetFiles (Cache-Control only on 200, no gzip/HEAD/Vary handling) - Remove _accepts_gzip_static/_GZIP_COMPRESS_LEVEL parser helpers - Remove fork-only tests/hermes_cli/test_web_static.py (gzip coverage) Fork's immutable-cache semantics are preserved; serve_css + assets mount now byte-identical to upstream main. Verified: 136 web_server tests pass.
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.
Extract-salvage of #28543 by @sea-monsters — the cache-header core, re-implemented onto current main (original 11,457 commits behind; mount_spa moved and serve_css gained rewrites since).
Context — what this changes for users
Every dashboard load re-transferred the full JS/CSS bundle: main served hashed /assets files with NO cache headers. Vite content-hashes the filenames, so Cache-Control: public, max-age=31536000, immutable is safe and makes repeat loads hit the browser cache. index.html KEEPS no-store (the document must always revalidate to pick up new asset hashes).
Scope honesty — what was deliberately dropped
The PR's hand-rolled gzip (60-line Accept-Encoding parser + per-request level-6 compression, no output cache) was dropped: the dashboard binds 127.0.0.1 by default, where per-request gzip is a net CPU pessimization with zero transfer win. If network-proxy deployments want compression, starlette's GZipMiddleware is the 3-line path — noted for a follow-up, not bundled here. The PR title's "plugin cache-busting" was not present in its head commit (verified).
Verification
Header tests on /assets/*.js + serve_css; no-store intact on index.html; 404s excluded (header only on 200); mutation: both header sites removed → 2 tests fail; ruff clean. Simplify pass verified no non-hashed files live under /assets (web/public copies to dist root).
Closes #28543.