Closed Bug 1269286 Opened 9 years ago Closed 9 years ago

Caching too agressively

Categories

(Core :: Networking: Cache, defect)

45 Branch
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: galmok, Unassigned)

Details

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:45.0) Gecko/20100101 Firefox/45.0 Build ID: 20160407164938 Steps to reproduce: Start windows pc. Start firefox. Load website (has been loaded many times before in previous sessions). Observe that 1 file in particular gets 304'ed even though it is changed on the server. Actual results: The one file has this request header: Host: ebutler.dk User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: da,en-US;q=0.7,en;q=0.3 Accept-Encoding: gzip, deflate Referer: [hidden] Cookie: [hidden] Connection: keep-alive Firefox claims this is the server response: Accept-Ranges: bytes Content-Encoding: gzip Content-Length: 137 Content-Type: text/xml Date: Fri, 08 Apr 2016 08:20:06 GMT Etag: "26a9a5cef733d01:0" Last-Modified: Mon, 19 Jan 2015 14:54:21 GMT Server: Microsoft-IIS/8.0 Vary: Accept-Encoding X-Powered-By: ASP.NET Firefox doesn't actually query the server which means it fakes a server response. Restarting IIS does not change anything. The static content file is correct on the server (including the pre-gzipped version). Restarting the browser doesn't help. Reloading the site doesn't help. Force-reloading the site does help, but most user we have are unaware of this option. Expected results: Firefox should at least contact the server to see if the file is changed and the file should be download by Firefox. This is the actual server response for this file (checked with curl and other browsers): HTTP/1.1 200 OK Content-Type: text/xml Last-Modified: Mon, 02 May 2016 07:54:46 GMT Accept-Ranges: bytes ETag: "ec85ede447a4d11:0" Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET Date: Mon, 02 May 2016 08:44:35 GMT Content-Length: 179
Component: Untriaged → Networking: Cache
Product: Firefox → Core
Because Date: Fri, 08 Apr 2016 08:20:06 GMT is quit in the past and there is no Cache-control: no-cache response header, we use heuristic caching and decide w/o asking the server the resource is valid. Add Cache-control: no-cache response header.
Status: UNCONFIRMED → RESOLVED
Closed: 9 years ago
Resolution: --- → INVALID
Of course there is no "Cache-control: no-cache" as the file may be cached. But that only means caching unless the server has a newer version. Firefox does not even contact the server to see if there is a newer version! Please note that Chrome, IE, Edge, Opera and other browser have no issue in checking teh server for a newer version and fetching it if need be. We are working on a workaround that appends a random query option to the file to ensure we get a fresh version. I don't think our webserver (IIS 8.0) allows controlling caching on individual static files.
(In reply to galmok from comment #2) > Of course there is no "Cache-control: no-cache" as the file may be cached. > But that only means caching unless the server has a newer version. Firefox > does not even contact the server to see if there is a newer version! Please > note that Chrome, IE, Edge, Opera and other browser have no issue in > checking teh server for a newer version and fetching it if need be. That's the whole purpose of the heuristic caching. Every browser may do it a bit differently tho. However, this behavior is in Firefox for a very long time. > > We are working on a workaround that appends a random query option to the > file to ensure we get a fresh version. I don't think our webserver (IIS 8.0) > allows controlling caching on individual static files. It does, I believe. You can simply add the header manually, even for a whole directory, I think. Tho I'm not a super expert here, I've already done that several times myself on my local testing server.
Is this heuristic caching documented anywhere?
If you would like conditional revalidation just give it a very short TTL e.g. Cache-Control: max-age=1
You need to log in before you can comment on or make changes to this bug.