Only lowercase directives are honored for Cache-Control header
Categories
(Core :: Networking: Cache, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox130 | --- | fixed |
People
(Reporter: mail, Assigned: smayya)
References
(Blocks 1 open bug)
Details
(Whiteboard: [necko-triaged][necko-priority-queue])
Attachments
(1 file, 1 obsolete file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Steps to reproduce:
I've been developing a web application where the framework generates HTTP response headers as follows for static resources to ensure ETag is honored:
cache-control: No-Cache
last-modified: Sat, 24 Feb 2024 12:42:28 GMT
etag: "12787-1708778548"
In Chromium, the cache-control directive is honored and I can observe a request always being made to determine whether the resource is still cached or not. In Firefox however, the default heuristic caching behavior still applies and requests are not always being made. I managed to work around this by instructing the framework to use lowercase directives as follows:
cache-control: no-cache
After this change, the caching behavior in Firefox is the same as in Chromium.
This strikes me as unexpected, given the documentation on MDN at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control:
Caching directives are case-insensitive. However, lowercase is recommended because some implementations do not recognize uppercase directives.
Actual results:
Caching directive is only honored when using a lowercase directive:
cache-control: no-cache
Expected results:
Caching directive is honored no matter the casing. Therefore, both
cache-control: no-cache
and
cache-control: No-Cache
should result in the same caching behavior, consistent with MDN documentation of directives being case-insensitive.
![]() |
||
Updated•1 year ago
|
Comment 1•1 year ago
|
||
Thank you for the bug report.
This is definitely something we should rectify, and I think it should be easy to do so.
We need to change CacheControlParser to use custom tokens like we do here
Updated•1 year ago
|
Comment 2•11 months ago
|
||
This might actually affect performance - when we don't cache things properly.
Comment 3•11 months ago
|
||
(In reply to Valentin Gosu [:valentin] (he/him) from comment #1)
Thank you for the bug report.
This is definitely something we should rectify, and I think it should be easy to do so.
We need to change CacheControlParser to use custom tokens like we do here
Instead of using CheckWord, we need to add the custom tokens and check them like this instead.
Assignee | ||
Updated•10 months ago
|
Assignee | ||
Comment 4•10 months ago
|
||
Assignee | ||
Comment 5•10 months ago
|
||
Depends on D216486
Updated•10 months ago
|
Updated•10 months ago
|
Comment 7•10 months ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/2767e60da4f2
https://hg.mozilla.org/mozilla-central/rev/ae2a7f70cc15
Updated•7 months ago
|
Description
•