Page Speed Module Cache-Control no-transform Headers
How to keep Cache-Control no-transform while ModPagespeed optimizes, using the Headers directive and merge vs add.
The thread How to make ModPagespeed send a “Cache-Control: no-transform” header while still doing its work on the ModPagespeed discuss group is about a common conflict: you want ModPagespeed (the Apache or nginx page-speed module) to keep rewriting and optimizing responses, but you also need intermediaries and browsers to see Cache-Control: no-transform so they do not alter the payload. The cluster material is a single confirmed workaround from that discussion; this page states that fix in plain terms and how to sanity-check headers on your site.
Cache-Control no-transform: why ModPagespeed sites need it
Section titled “Cache-Control no-transform: why ModPagespeed sites need it”The no-transform cache directive tells caches and transforming proxies they must not change the response body or encoding. Operators often add it when a CDN, security appliance, or mobile optimizer might otherwise compress, minify, or re-encode HTML or assets in ways that break signatures, integrity checks, or licensed font delivery. ModPagespeed itself performs transformations (combine, minify, lazy-load, and similar). The goal in the ModPagespeed discuss thread is not to disable the module, but to emit the correct Cache-Control metadata while optimization still runs.
What goes wrong without an explicit header policy
Section titled “What goes wrong without an explicit header policy”If Cache-Control is missing no-transform, a shared cache may legally transform the response. If you only set no-transform at the CDN but ModPagespeed overwrites or duplicates Cache-Control at the origin, visitors can still see inconsistent behavior. The discuss thread is specifically about making ModPagespeed send the header, not only setting it elsewhere.
ModPagespeed Headers directive: merge instead of add
Section titled “ModPagespeed Headers directive: merge instead of add”Configuring outbound headers through ModPagespeed’s Headers machinery is what resolved the issue for the reporter. Using merge rather than add when applying the directive was the difference between a working Cache-Control line and one that did not behave as expected—typically because add can create duplicate or conflicting header fields where merge combines into a single coherent value.
Thanks a lot! The “Headers” directive did the trick (although I replaced “add” by “merge”).
— David Scherfgen, How to make ModPagespeed send a “Cache-Control: no-transform” header while still doing its work
In practice, when you introduce or extend Cache-Control through ModPagespeed:
- Use the module’s Headers directive (or equivalent filter configuration documented for your ModPagespeed build) as the control point—not only the web server’s global header block—so the value survives the module’s own response pipeline.
- Prefer merge when combining
no-transformwith existingCache-Controltokens such asmax-age,public, orprivate, so clients receive oneCache-Controlheader field instead of conflicting duplicates.
The cluster does not include the full pagespeed.conf snippet from the thread; treat the Google Groups discussion as the source for any version-specific parameter names before you apply changes in production.
When to set no-transform at the server vs at the CDN
Section titled “When to set no-transform at the server vs at the CDN”| Layer | Typical use |
|---|---|
| ModPagespeed (origin) | You rely on the module’s transformations and need no-transform on the final origin response the CDN fetches. |
| CDN or reverse proxy | You only need no-transform on the edge response and ModPagespeed is off or bypassed for that path. |
| Both | Easy to drift: verify the browser-facing response, not only the origin curl, after any change. |
Common mistakes with no-transform and page-speed modules
Section titled “Common mistakes with no-transform and page-speed modules”- Duplicating
Cache-Controlwithadd: MultipleCache-Controlheaders or mixed directives can make caches ignoreno-transform. The thread’s fix was explicitly to switch to merge. - Setting headers only in the web server block: If ModPagespeed runs later in the chain, those headers may not reflect what clients see unless configured through the module’s Headers path.
- Expecting
no-transformto disable ModPagespeed: The module can still rewrite at the origin;no-transformgoverns downstream cache behavior on the response you emit. - Not re-testing through the full path: Validate through the same hostname, TLS, and CDN orange-cloud path users use.
Related performance checks (Chrome Lighthouse)
Section titled “Related performance checks (Chrome Lighthouse)”Page-weight and cache behavior are separate concerns. After header work, you may still run performance audits in the browser. Google documents running Lighthouse from Chrome DevTools in Lighthouse: Optimize your website. Lighthouse scores do not replace a header inspection for no-transform; use both when you are tuning speed and cache policy.
How to check this on your site
Section titled “How to check this on your site”- Request a representative HTML or asset URL with
curl -sIagainst your public hostname and confirm a singleCache-Controlfield includesno-transformwhen you expect it. - Repeat the same request with ModPagespeed enabled and disabled (or on a staging host) to see whether the module changes
Cache-Controlpresence or shape. - In Chrome DevTools Network, select the document, open Headers, and compare Response Headers with your origin
curloutput to catch CDN rewrites. - Optionally run Lighthouse: Optimize your website on the same URL to ensure optimizations still meet your performance budget after header changes.
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact sentence you are asking about, and we will correct or expand it.