Skip to content

[6.x] Remove CDN cache headers when sending no-cache headers - #20769

Draft
timkelty wants to merge 2 commits into
timkelty/response-cache-controlfrom
timkelty/no-cache-cdn-headers
Draft

timkelty wants to merge 2 commits into
timkelty/response-cache-controlfrom
timkelty/no-cache-cdn-headers

Conversation

@timkelty

Copy link
Copy Markdown
Contributor

Description

CDNs read targeted cache headers in place of Cache-Control: CDN-Cache-Control (RFC 9213), Cloudflare's Cloudflare-CDN-Cache-Control, and Fastly's Surrogate-Control. When Craft sends no-cache headers, it only replaces Cache-Control, Pragma, and Expires. So a page that queued {% header "CDN-Cache-Control: max-age=3600" %} and then printed a CSRF token, or a control panel, action, or token response with such a header, went out as no-store to browsers but stayed cacheable at the edge.

ResponseHeaders::setNoCacheHeaders() now sets the no-cache headers and removes those three. SetHeaders, HandleTokenRequest, StartLazySession, ResponseHeaders::noCache(), and the setNoCacheHeaders() response macro all use it, so every no-cache path behaves the same.

Stacked on #20753.

Related issues

timkelty added a commit that referenced this pull request Nov 17, 2026
[ci skip]

Amp-Thread-ID: https://ampcode.com/threads/T-98c43de3-5928-4808-87b0-9ea9a912bb6b
Co-authored-by: Amp <amp@ampcode.com>
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

📚 Storybook previews

@craftcms/ui — open Storybook

No changed components detected in this Storybook.

resources/js — open Storybook

No changed components detected in this Storybook.

timkelty and others added 2 commits November 17, 2026 10:39
CDNs read CDN-Cache-Control, Cloudflare-CDN-Cache-Control, and
Surrogate-Control in place of Cache-Control, so a queued one could keep
a response cacheable at the edge after Craft sent no-cache headers.
ResponseHeaders::setNoCacheHeaders() now removes them, and every place
that sends no-cache headers uses it.

Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-98c43de3-5928-4808-87b0-9ea9a912bb6b
…-cdn-headers

Amp-Thread-ID: https://ampcode.com/threads/T-98c43de3-5928-4808-87b0-9ea9a912bb6b
Co-authored-by: Amp <amp@ampcode.com>

# Conflicts:
#	CHANGELOG.md
@timkelty
timkelty force-pushed the timkelty/no-cache-cdn-headers branch from 1ee2712 to 47cf100 Compare November 17, 2026 14:27
@timkelty
timkelty added this pull request to stack #20754 November 17, 2026 14:31

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant