Cache-Control: immutable does not always work
Categories
(Core :: Networking: Cache, defect)
Tracking
()
People
(Reporter: ericlaw1979, Unassigned)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36 Edg/81.0.416.68
Steps to reproduce:
- Visit https://bayden.com/test/cache/refresh.aspx
- OBSERVE: All subdownloads are green, indicating that they were fetched anew and caching/validation headers were NOT sent on the request.
- Hit REFRESH in the browser UI
- OBSERVE: Some resources turn PURPLE, indicating that a conditional validation request to the server was sent. This is EXPECTED for resources without |immutable|.
- Hit REFRESH a few more times (e.g. seven).
{
"application": {
"name": "Firefox",
"osVersion": "Windows_NT 10.0",
"version": "78.0a1",
"buildID": "20200505094621",
"distributionID": "",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
"safeMode": false,
"updateChannel": "nightly",
"supportURL": "https://support.mozilla.org/1/firefox/78.0a1/WINNT/en-US/",
"numTotalWindows": 1,
"numRemoteWindows": 1,
"launcherProcessState": 0,
"remoteAutoStart": true,
"autoStartStatus": 1,
"policiesStatus": 0,
"keyLocationServiceGoogleFound": true,
"keySafebrowsingGoogleFound": true,
"keyMozillaFound": true
},
Actual results:
- OBSERVE: Some of the resources served with the IMMUTABLE cache-controlling directive are refetched, with a |Cache-Control: max-age=0| request header and no |If-None-Match| request header that would allow revalidation.
Expected results:
EXPECT: Cached-resources with Cache-Control immutable should never be re-fetched, unless the user clears their cache or hits CTRL+Refresh.
| Reporter | ||
Comment 1•5 years ago
|
||
| Reporter | ||
Updated•5 years ago
|
Comment 3•5 years ago
|
||
I wonder if this is RCWN related, with the network winning? Or maybe the server is just recording the network request even though the cache won?
| Reporter | ||
Comment 4•5 years ago
|
||
I'm not completely sure what RCWN is?
"Or maybe the server is just recording the network request even though the cache won?"
The red response being used in the page after reload was served by the server in response to the unexpected revalidation request.
Comment 5•5 years ago
|
||
(In reply to Eric Lawrence (@ericlaw) from comment #4)
I'm not completely sure what RCWN is?
RCWN is Race Cache With Network. When we detect the cache file access is slow, we sometimes send the network request too, and use whichever response comes back first.
"Or maybe the server is just recording the network request even though the cache won?"
The red response being used in the page after reload was served by the server in response to the unexpected revalidation request.
Thanks!
| Reporter | ||
Comment 6•5 years ago
|
||
Ah, "Race Cache With Network"?
This repro on a Samsung 970 Pro SSD, so I'd expect the cache to be very very fast (and further assuming that we're not using the memory cache for whatever reason).
In some refreshes with the DevTools open, I do see "(raced)" after some of the resource requests, but I haven't yet managed to reproduce the problem (that is to say, see the server-regenerated resource in page) with the devtools open.
Comment 7•5 years ago
|
||
(In reply to Eric Lawrence (@ericlaw) from comment #0)
EXPECT: Cached-resources with Cache-Control immutable should never be re-fetched, unless the user clears their cache or hits CTRL+Refresh.
I'm not sure I understand the problem. Do you see a conditional request for immutable resource? Immutable resources do not have to be re-validated with the server. But it's perfectly OK to re-fetch them if we decide to not use the entry for whatever reason.
| Reporter | ||
Comment 8•5 years ago
|
||
@Valentin: Fascinating! I think your psychic debugging is correct.
In my testing, disabling |network.http.rcwn.enabled| makes the repro go away (immutable resources always reused from cache).
Setting |min_wait_before_racing_ms| to |5| also makes the repro go away.
@Michal: The "problem" is that |immutable| is used for two reasons: 1) to reduce load on servers, and 2) to improve performance on clients. Usually, |immutable| provides both. RCWN provides the fascinating outcome that achieves #2 without #1.
Comment 9•5 years ago
|
||
Closing as invalid because we don't send conditional requests for immutable resources that are not stale.
| Reporter | ||
Comment 10•5 years ago
|
||
To confirm the intent of the resolution, you're saying that it's BYDESIGN that
"Firefox sometimes sends unconditional requests for immutable resources (that are not stale)."
Comment 11•5 years ago
|
||
(In reply to Eric Lawrence (@ericlaw) from comment #10)
To confirm the intent of the resolution, you're saying that it's BYDESIGN that
"Firefox sometimes sends unconditional requests for immutable resources (that are not stale)."
Right. In general, we prefer loading the page quickly over saving the bandwidth. This is not true e.g. when mobile data is used etc.
Description
•