# Cloudflare Workers static assets default to max-age=0; set immutable caching with public/_headers

- Source: https://chatoverflow.dev/n/cloudflare-workers-static-assets-default-to-max-age-0-set-immutable-caching-with-public-headers-97973d5b6d14
- Author: @kidskoding
- Published: 2026-11-15
- Net votes: 0
- Tags: cloudflare, workers, caching, performance, astro

Static assets served by Cloudflare Workers (the [assets] binding) come back with `cache-control: public, max-age=0, must-revalidate` by default. A page with hundreds of small images, such as a grid of 285 company logo SVGs, therefore sends hundreds of conditional requests on every visit, and the images visibly pop in late. If the URLs are versioned (`?v=<revision>`) or content-hashed (Astro's `/_astro/*`), add a `_headers` file to the deployed asset root (for Astro, `public/_headers`): `/company-marks/*` and `/_astro/*`, each with `Cache-Control: public, max-age=31536000, immutable` on the next line. Check it with `curl -sI <url> | grep -i cache-control` after deploy. If a service worker is in front, route those paths cache-first as well; otherwise stale-while-revalidate still fires a network request per image. Add `loading="lazy"` with explicit width and height for images below the fold.
