A cached invoice cannot be corrected, and immutable is not why
“We reissued an invoice after a pricing error and the customer swears the download link still gives them the old PDF with the old total. It is correct in our admin, it is correct if I open it in a private window, and support cannot reproduce it on their machines. I do not know whether to blame our storage, our CDN or the customer.”
A document endpoint is easy to set up the way you set up a stylesheet. The invoice is a file, you have it on disk or in a bucket, and the usual advice for serving files is a long freshness lifetime so that browsers stop asking for it. So the handler ends up sending something like this:
Cache-Control: private, max-age=31536000, immutable
Then a price is wrong, somebody reissues the invoice at the same URL, and the customer keeps downloading the old total. Support cannot reproduce it, because support has never loaded that URL before. The customer cannot fix it, because the thing holding the old document is their own browser and nothing on the page tells them so.
This post is about what each part of that header actually does to a document that can be
reissued. The short version is not the one we expected: immutable was not the part that
did the damage in either browser engine we tested, the max-age was all of it, and the
directive that stops the invoice being written to the customer's disk is a different
directive again from the one that fixes the staleness.
One thing up front. The public report that put this on our topic list has since been deleted, so this post cites it for nothing and rests entirely on the two RFCs and on measurements run for it. Nothing below is a claim about what any particular project shipped.
What the header claims, in the spec's own words
immutable is RFC 8246, a short
standards-track document from September 2017. Its abstract states the promise:
The immutable HTTP response Cache-Control extension allows servers to identify resources that will not be updated during their freshness lifetime. This ensures that a client never needs to revalidate a cached fresh resource to be certain it has not been modified.
Section 2 is the normative part:
When present in an HTTP response, the immutable Cache-Control extension indicates that the origin server will not update the representation of that resource during the freshness lifetime of the response. Clients SHOULD NOT issue a conditional request during the response's freshness lifetime (e.g., upon a reload) unless explicitly overridden by the user (e.g., a force reload).
Read that as a precondition rather than as a performance setting. The server is not asking for fewer requests, it is asserting a fact about itself: this representation will not change while the response is fresh. An invoice that can be reissued at the same URL makes that assertion false.
RFC 8246 says plainly which deployment it was written for. Its introduction describes content providers who
never create more than one variant of a sub-resource, because they use "versioned" URLs. When these resources need an update, they are simply published under a new URL, typically embedding an identifier unique to that version of the resource in the path
and the example header in section 2.2 is Cache-Control: max-age=31536000, immutable,
character for character the one at the top of this post. The directive assumes the
versioned-URL pattern is already in place. It is a label for a property the URL scheme
gives you, not a mechanism that gives you the property.
Three hundred and sixty-five days, exactly
max-age=31536000 is 31,536,000 seconds, which is 365 days to the second.
RFC 9111 section 4.2.1 says a private cache
computes the freshness lifetime straight from that value, and section 5.2.2.1 says
max-age "indicates that the response is to be considered stale after its age is greater
than the specified number of seconds".
So an invoice fetched today, 19 November 2026, is fresh in that browser until 19 November 2027. Not "about a year", and not "until the session ends". A specific date, computed by the client, from a number your handler chose.
RFC 9111 section 4.2 is candid about what that number means:
Generally, origin servers will assign future explicit expiration times to responses in the belief that the representation is not likely to change in a semantically significant way before the expiration time is reached.
A belief is exactly what it is, and for a document that gets corrected it is a false one.
What four header sets actually do
We served a small PDF from a local server at a fixed URL, read it from a real browser,
changed the invoice on the server, and read it again, counting the requests the server
received. We did this in two browser engines, Chromium (140 and 157) and Firefox 141, each
driven by Playwright with a fresh profile per header set. A read is a same-origin fetch in
default cache mode, which is the browser's HTTP cache, and the bytes that come back are
decoded and checked for the invoice total, so "reads the corrected invoice" below means the
corrected number was in the bytes rather than that a request happened. Both engines gave
the same answer in every cell. The reload paths are covered further down.
Cache-Control sent |
reads the corrected invoice? | requests the server saw after the correction | PDF bytes written into the browser profile |
|---|---|---|---|
private, max-age=31536000, immutable |
no | 0 | yes |
private, max-age=31536000 |
no | 0 | yes |
private, no-cache |
yes | 1 | yes |
private, no-store |
yes | 1 | no |
The first row is the failure in full. After the invoice was corrected on the server, the browser delivered the superseded PDF and the server received no request at all. Not a 304, not a conditional request: nothing. From the server's logs that customer never asked for their invoice again, which is why this does not show up in your access logs as a problem.
It also survives the obvious remedies. We closed the browser entirely and relaunched it
against the same profile three times, in both engines. Every launch delivered the old
invoice, and every launch sent zero requests. The PDF was sitting in one file inside the
profile, at Default/Cache/Cache_Data/17906b90b9ef3623_0 in Chromium and under
cache2/entries/ in Firefox, and we found it there by searching the profile directory for
the invoice text.
immutable was not the part that hurt
Rows one and two of that table are identical, and that is the finding we did not expect.
With and without immutable, every step we ran produced the same request count, the same
status codes and the same bytes, in both engines. The 365 days of staleness came from
max-age=31536000 on its own.
The second engine matters here more than usual. Chromium has never implemented immutable,
so on its own it could not have shown a difference. Firefox has supported it since version
49, and it still made none on any path we could drive.
That is consistent with what the directive is for. immutable does not make a response
fresher; max-age already did that. All it changes is whether a reload revalidates a
response that is still fresh, and RFC 8246 carves out the user even then: clients should
skip revalidation "unless explicitly overridden by the user (e.g., a force reload)", and
section 3 says force reloads, "typically indicated through no-cache request attributes,
SHOULD ignore the immutable extension as well". The paths we drove came out the same way
with and without the directive:
- Reloading the document itself (the invoice opened as a page, then
location.reload()) revalidated and returned the corrected invoice in both engines. - Reloading a page that reads the invoice with
fetch, or loads it as an image, sent no request for the invoice in either engine. - A
fetchwith the reload cache modes reached the server and returned the corrected invoice in both engines.
The practical consequence is worth stating in plain terms. The escape hatch exists, only the
reader can pull it, and only if somebody talks them through a reload of a PDF they have no
reason to doubt. Removing immutable from that header buys you nothing on its own, because
the default path, opening the link again, never revalidated either way.
Nothing invalidates a document the server fixed by itself
The reason this persists is in RFC 9111 section 4.4. Caches do invalidate things, but only along the path a request travels:
A cache MUST invalidate the target URI (Section 7.1 of [HTTP]) when it receives a non-error status code in response to an unsafe request method (including methods whose safety is unknown).
and then, explicitly:
Note that this does not guarantee that all appropriate responses are invalidated globally; a state-changing request would only invalidate responses in the caches it travels through.
A corrected invoice is almost never produced by a request that travels through the customer's browser. It is produced by someone in your admin, by a nightly job, by a requeue after a rejection. None of those passes through the cache holding the stale copy, so none of them can invalidate it, which is why "we redeployed" and "we purged the CDN" both leave this bug exactly where it was.
There is one blunt instrument. A response carrying Clear-Site-Data: "cache" tells the
browser to drop everything it has cached for your origin. We served it on an ordinary page,
and in both engines the next read of the invoice went to the server and returned the
current one. But it only reaches a customer who loads that page from you, it empties the
whole origin's cache rather than one invoice, and MDN lists Chrome's support for the
"cache" value as partial. It is a cleanup for a mistake already shipped, not a way to
serve documents.
private is about where it is stored, not about who reads it
The other half of that header is private, and it is easy to read as a privacy control.
RFC 9111 section 5.2.2.7 defines it as a storage location rule:
The unqualified private response directive indicates that a shared cache MUST NOT store the response (i.e., the response is intended for a single user). It also indicates that a private cache MAY store the response
The spec then says what it is not, in a note attached to the same section:
This usage of the word "private" only controls where the response can be stored; it cannot ensure the privacy of the message content.
And "single user", in section 1, means a cache "dedicated to a single user; often, they are deployed as a component of a user agent". The unit is the browser profile, not the person. On a shared machine, or a kiosk, or one login that two people in an office use, the single user the spec has in mind is the browser, and everyone who opens that browser is inside it.
Our measurements line up with the text on both halves. A policy library,
http-cache-semantics 4.2.0, reports that same response as not storable at all in a
shared cache and storable in a private one, which is the directive working correctly.
Meanwhile the invoice was a readable file in the profile directory for three of our four
header sets, including private, no-cache, in both engines.
That last point is the one to take away from this section: no-cache fixes the staleness
and does nothing about the storage. Only no-store kept the document out of the profile.
What to send instead
Two options, and the choice is about your URLs, not your headers.
Give the document a versioned URL. This is the pattern RFC 8246 was written for, and if
you adopt it the long max-age becomes true instead of merely convenient. A reissue is
published at a new path, the old path keeps serving the old document because that is now
the correct answer, and the question of invalidating a year-old cache entry never comes up.
It costs you a column holding the current URL and a rule that your pages never hardcode the
old one.
Or keep the stable URL and revalidate. Send no-cache with a strong validator. RFC 9111
section 5.2.2.4 defines the response directive as meaning the response "MUST NOT be used to
satisfy any other request without forwarding it for validation and receiving a successful
response". In our runs the steady-state cost of this was one conditional request per read
answered with a 304 carrying no body, and the correction reached the reader on the first
read after it was made.
If the document should not be left on the device at all, that is a third and separate
decision, and the directive for it is no-store.
What none of this needs is a shorter max-age. A week of a wrong invoice is not better
than a year of one in any way that matters to the person holding it.
What this does not cover
The browser measurements are two engines: Chromium (140.0.7339.16 and 157.0.8103.78) and
Firefox 141.0, headless, driven by Playwright. Safari, which also implements immutable, was
not tested. Neither was any browser's own reload button: a headless browser has no toolbar,
so we drove location.reload() and the Fetch API cache modes instead. That is the same
cache and the same request directives, but it is not a person clicking, and a user's reload
of a page that embeds the invoice is the one place left where immutable could still make
a difference in Firefox or Safari.
We also tested no shared cache. Every claim about proxies and CDNs above comes from the RFC text, and the only shared-cache behaviour we checked was a policy library's decision not to store the response, which is a decision about a response, not a deployed proxy.
Every quotation here was checked against the RFC Editor's published text of RFC 8246 and RFC 9111.
Finally, this is about one URL serving a document whose content can change. If your invoice URLs already carry a version, or already revalidate, there is nothing here for you.