Is Firefox cache-javascript and use it without request if there is a request in the path?

What I would like to do is add a query string at the end of the javascript path so that whenever my application is updated to a new version, javascript is loaded. As long as the query string is the same, I want it to continue to use the cached version without the http request in order to check if the script has changed.

The way I do this in PHP is to read the CVS tag. When I create the HTML for output, I read the CVS tag and use it to add the javascript to the end of the path so that it creates a script tag that looks like this:

<script src="javascript/messages/shipments.js?TPRSAPPS-DEV2_090828145712237-BRANCH" type="text/javascript"></script>

Until the application has changed, the tag will remain the same, so the query string will also be. The browser should cache JS, and not perform a network request at all, because the validity period is a distant future. Each time the application is updated, this query string will change, and the browser should download it.

This works fine in IE8. My problem is with Firefox. Firefox caches files, but the next time I load the page, Firebug shows a 304 response, indicating that it still complied with the network request for the file and then found that it had not changed.

So my question is: does firefox ignore the expires header and javascript cache when there is a query string?

Related: what does firefox not cache? Obviously, Rails does something similar. But this does not answer my question.

Here is the answer that I am returning to this file:

https://appdev.prsx.net/~jhargett/PRSApps-Motorlog/javascript/menuReader.js?TPRSAPPS-DEV2_090828145712237-BRANCH-DIFFERENT

HTTP/1.1 304 Not Modified
Date: Mon, 03 Oct 2011 18:35:26 GMT
Server: Apache/2.2.3 (Red Hat)
Connection: close
Etag: "179010-3f8-49a9a74334200"
Vary: Accept-Encoding

"" Firebug :

Last Modified   Mon Oct 03 2011 13:35:26 GMT-0500 (Central Daylight Time)
Last Fetched    Mon Oct 03 2011 13:35:26 GMT-0500 (Central Daylight Time)
Expires Fri Oct 28 2011 18:33:31 GMT-0500 (Central Daylight Time)
Data Size   345
Fetch Count 12
Device  disk
+5
4

Firefox , , GET, , :

  • Vary, .
  • , .
  • " ", .
  • " ", , SSL-.
  • no-store , .
  • , Expires max-age, revalidate.
  • , ( ​​ " " ).

, GET, 200.

, , HTTP Firefox, , .

, https://developer.mozilla.org/en/HTTP_Logging, , , , GET, ( "nsHttpChannel:: CheckCache enter" , ).

+6

, , - , , , .

Firefox HTTP-, , . , firefox , IE.

firefox - ( , ..). , firefox ( ). , firefox .

, , .

0

, , /- . , - shipments_v2.js shipments_(unix_timestamp).js. .

0

As explained in Boris's answer, one of the conditions causing the conditional query is the presence of the Vary header. Normally you do not want to delete changes in Accept-Encoding, but what you can do and what is good to do if you have a version of URL rights is to leave the browser invalid for verification. In your case, this is the Etag header. It can also be the Last-Modified header. Sample code for varnish for this may look like this:

  sub vcl_recv {
  [..]
        if (req.url ~ "\?v=\w+$") {
          set req.http.X-Versioned = "1";
        }
  [..]
  }

  sub vcl_deliver {
  [..]
        if (req.http.X-Versioned) {
          unset resp.http.Etag;
        }
  [..]
  }
0
source

All Articles