Why does firefox contact the server to determine if my files are modified?

I have some static content on my website where I set up caching (using Asp.NET MVC). According to Firebug, the first time a page is opened, Firefox sends this request:

GET /CoreContent/Core.css?asm=0.7.3614.34951 Host: 127.0.0.1:3916 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Accept: text/css,*/*;q=0.1 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://127.0.0.1:3916/Edit/1/101 Cookie: .ASPXAUTH=52312E5A802C1A079E2BA29AA2BFBC5A38058977B84452D62ED52855D4164659B4307661EC73A307BFFB2ED3871C67CB3A9AAFDB3A75A99AC0A21C63A6AADE9A11A7138C672E75125D9FF3EFFBD9BF62 Pragma: no-cache Cache-Control: no-cache 

To my server answers:

 Server: ASP.NET Development Server/9.0.0.0 Date: Mon, 23 Nov 2009 18:44:41 GMT X-AspNet-Version: 2.0.50727 X-AspNetMvc-Version: 1.0 Cache-Control: public, max-age=31535671 Expires: Tue, 23 Nov 2010 18:39:12 GMT Last-Modified: Mon, 23 Nov 2009 18:39:12 GMT Vary: * Content-Type: text/css Content-Length: 15006 Connection: Close 

So far so good. However, if I update Firefox (and not the update to clear the cache, just normal), during this update cycle, Firefox will again go to the server with this request:

 GET /CoreContent/Core.css?asm=0.7.3614.34951 Host: 127.0.0.1:3916 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729) Accept: text/css,*/*;q=0.1 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://127.0.0.1:3916/Edit/1/101 Cookie: .ASPXAUTH=52312E5A802C1A079E2BA29AA2BFBC5A38058977B84452D62ED52855D4164659B4307661EC73A307BFFB2ED3871C67CB3A9AAFDB3A75A99AC0A21C63A6AADE9A11A7138C672E75125D9FF3EFFBD9BF62 If-Modified-Since: Mon, 23 Nov 2009 18:39:20 GMT Cache-Control: max-age=0 

to which my 304 Not Modified server responds.

Why is Firefox issuing this second request? In the first answer, I said that the cache does not expire within a year (I intend to use the request parameters when something changes). Should I add another response header to prevent this extra circuit?

Change It doesn't matter if I click the update, or again on the page (or another URL that links to the same external files). Firefox does the same. In addition, I am not saying that this is a mistake in FF, I am just wondering if there is another heading that I can set, which means: "This document will never change, do not bother me again."

+4
source share
2 answers

Apparently, the problem is that the Vary: * header is added to the response. To remove this in Asp.Net, add this to web.config in the <system.web> section:

 <caching> <outputCache omitVaryStar="true"/> </caching> 

It seems to me that this switch is β€œyes, I want to work, not broken”, but as soon as you find it, the click is trivial.

0
source

This behavior seems "by design" to all modern browsers. In IE, you can investigate the same situation. Pressing F5 always forces the browser to check whether the content has been changed. The cache flush request browser does not send the Last-Modified header, and the server should return HTTP 200 (not HTTP 304), so 304 is not so bad in your situation.

+1
source

All Articles