Static assets get no configurable headers on native Cloudflare deploys of framework apps

Offen
#647 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@dvkam arbeitet bereits daran.

Seit 02.11.2026.

  • #670 von @dvkam — offen

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
50/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript, vite
Bereich
cloud

Rechercherichtung

Start by tracing uploadAssets, readGeneratedAssetHeaders, and planAssetWorkerBypass for native Cloudflare deploys, then compare their behavior with the TanStack Start asset configuration described here. Check or add coverage for user-authored _headers and fingerprinted assets; done means the reported cache headers are applied to static assets, or the docs accurately describe the limitation.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Summary

A TanStack Start app deployed with void deploy --platform cloudflare serves its static assets without any configurable headers:

  1. A public/_headers file is copied to dist/client/_headers, but it never applies in production. uploadAssets ignores /_headers, and readGeneratedAssetHeaders only sends a file whose first line is Void's generated marker ("A user-authored _headers is not sent on this path").
  2. Void's own immutable caching for fingerprinted bundles never runs either. planAssetWorkerBypass only applies when the built wrangler.json has assets.run_worker_first: ["/**"], and the TanStack Start build has only "assets": { "directory": "../client" }. With the _headers file removed, the build generates no _headers at all.
  3. As a result, hashed files under /assets/ are served with Cloudflare's default Cache-Control: public, max-age=0, must-revalidate. Browsers revalidate every JS and CSS chunk on every page view.

This contradicts two docs pages:

  • guide/edge/static-assets.md ("Native Cloudflare deployments"): "With void deploy --platform cloudflare, generated JavaScript bundles with content fingerprints receive immutable caching."
  • guide/edge/headers.md ("Framework _headers files"): "Void reads _headers files produced by supported frameworks."

Reproduction

  • [email protected], @tanstack/[email protected], Vite 8, deployed with void deploy --platform cloudflare
  • void.config.ts sets cloudflare.cache.enabled, a custom domain route, a D1 binding and no routing options
  • public/_headers:
    /assets/*
      Cache-Control: public, max-age=31536000, immutable
    
  • After deploy, curl -sI https://<site>/assets/<hashed>.js shows cache-control: public, max-age=0, must-revalidate. CSS is the same.

I also tried routing.headers in void.config.ts ('/assets/*': ['Cache-Control: public, max-age=31536000, immutable']). In the local preview (vite preview in workerd), assets still came back with max-age=0, must-revalidate. I didn't deploy that variant, since the assets are served without starting the Worker, so I don't expect the rules to reach them.

Expected

One of these, for framework apps on native Cloudflare deploys:

  • send a user-authored _headers with the asset upload (as Wrangler does),
  • generate the immutable _headers for fingerprinted files even without run_worker_first, or
  • apply routing.headers to static assets.

Failing those, the docs should say framework apps on --platform cloudflare get no asset headers.

Workaround

A Response Header Transform Rule on the zone that sets Cache-Control: public, max-age=31536000, immutable for a 200 under /assets/.

Vorherrschende Sprache
TypeScript
Sterne
627
Forks
66
Ø Merge
13 Std. 57 Min.
Gemergte PRs (30 T.)
194

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/void

Alle Issues in voidzero-dev/void

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.