Skip to content

perf(dashboard): immutable cache headers on hashed assets (#28543 salvage) - #77693

Merged
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/28543-asset-cache-headers
Aug 3, 2026
Merged

perf(dashboard): immutable cache headers on hashed assets (#28543 salvage)#77693
kshitijk4poor merged 1 commit into
NousResearch:mainfrom
kshitijk4poor:salvage/28543-asset-cache-headers

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

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.

…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
kshitijk4poor enabled auto-merge (rebase) August 3, 2026 13:00
@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have comp/dashboard Web dashboard / control panel UI (dashboard/, landing) labels Aug 3, 2026
@kshitijk4poor
kshitijk4poor merged commit decf12e into NousResearch:main Aug 3, 2026
41 checks passed
@Ruanjq98

Ruanjq98 commented Aug 3, 2026

Copy link
Copy Markdown

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.
@kshitijk4poor
kshitijk4poor deleted the salvage/28543-asset-cache-headers branch August 5, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/dashboard Web dashboard / control panel UI (dashboard/, landing) P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants