1

I've been reading about problems people are having with browsers caching an old version of a javascript file and not downloading the new one when changes have been made. However every time I make a change to a js file, close the browser and open it up (or even refresh the page) the changes are reflected. I've tried this in IE9, FF13, Chrome18 and Safari 5.

Do newer browser versions have a way of determining if changes have been made to a .js file and then replacing the old with the new in the cache?

user784637
  • 15,392
  • 32
  • 93
  • 156
  • 1
    To put it into a number of letters long enough to satisfy the comment filter, no. It is, and always has been, a cache management issue. – Pointy Jun 20 '12 at 04:54

1 Answers1

1

This has nothing to do with the browser or browser version. This has to do with caching directives.

If your server is outputting headers, allowing the client to cache the resource, then it will be cached. If your server outputs headers directing the client to not cache, then it will (usually) not be cached.

See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

Browsers detect if they need to load a new version if the server specifies Must-Revalidate.

https://stackoverflow.com/a/8729854/362536

Community
  • 1
  • 1
Brad
  • 159,648
  • 54
  • 349
  • 530
  • I take it the default for apache2 (what I use) is to not allow the client to cache it? – user784637 Jun 20 '12 at 04:59
  • 1
    @user784637, There are so many config files for Apache2 floating around, that it is hard to say what your particular "default" options are. (Often, the config is setup by the package maintainer for your particular distribution.) The easiest way to check is to open up your browser's developer tools and check the headers on the JS files that are returned. You can also use a tool, such as Fiddler or Wireshark. – Brad Jun 20 '12 at 05:00
  • 1
    @user784637, Check this out: http://metaskills.net/2006/02/19/how-to-control-browser-caching-with-apache-2/ – Brad Jun 20 '12 at 05:02
  • Thanks Brad will try this out once I head home – user784637 Jun 20 '12 at 05:03
  • Not exactly **nothing** to do with browsers, it's a combination of the server sending the right directive and the UA following them. Browsers might not do so for various reasons (user settings or actions, programming errors or design, etc.). – RobG Jun 20 '12 at 05:23
  • Sure, but I'm trying to directly answer the question "Do newer browser versions..." by stating that this isn't some sort of new feature or fundamental change in how browsers work. If a truck hits a utility pole knocking my power out, I'd tell you the problem had nothing to do with my light switch. Obviously when the power comes back on, the lights won't come on without me turning the switch on, even if that wasn't the actual issue. – Brad Jun 20 '12 at 05:34