Skip to content

Cloudflare Integration Does Not Cache Hashed Assets #16692

@MA2153

Description

@MA2153

Astro Info

Astro                    v6.3.1
Vite                     v7.3.3
Node                     v25.9.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/cloudflare (v13.5.0)
Integrations             @astrojs/mdx (v5.0.4)
                         @astrojs/sitemap (v3.7.2)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When deploying an Astro site to Cloudflare Pages or Workers, the hashed static assets under /_astro/* (JavaScript bundles, CSS, images, and other build outputs) are served with a Cache-Control: public, max-age=0, must-revalidate header. This forces the browser to revalidate every asset with the server before each use — meaning every page load requires round-trips to confirm that fonts, scripts, stylesheets, and other resources are still current, even though their content-addressed URLs guarantee they are unchanged.

What's the expected result?

A Cache-Control: public, max-age=31536000, immutable header would be present to allow long-term caching of Astro assets, which is the intended behavior.

Link to Minimal Reproducible Example

https://github.com/MA2153/astro-assets-cf-repro

Participation

  • I am willing to submit a pull request for this issue.

Other Info

Here is the live website: https://astro-assets-cf-repro.ma2153.workers.dev

Here is the full AI summary of the bug: https://github.com/MA2153/astro-assets-cf-repro/blob/main/README.md

PR is #16571

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions