There aren't any other cache-related headers. Given the above, if I simply replace the files with new versions, can I assume that users' browsers will know not to use cached versions? (I assume if I replace the file, the ETag will change.)

What I'd like to avoid is a situation where a user's browser downloads the new version of index.html but continues to refer to a cached version of my.js, because that's likely to break things. I'd also like to know if I can rely on the users seeing the newer version of the site, or if some users will continue to see a cached version.

1 Answer
1

The browser will send the If-Modified-Since: and (if you have a recent browser) the If-None-Match: headers, the first refering to the Last-Modified: header, the latter containing the ETag. The server will send the new file, if the modification date is newer than the Last-Modified header. How the ETag changes will depend on your server, but in most cases this will be a hash over the file content.

So just make sure that both the file content changes and the modification date is up-to-date (e.g. by touch /var/www/your-file.js).

Thanks! I don't see my browser (Chrome) sending either of the If-* headers you mention, at least not I can't see them attached to the request when I look in Developer Tools. But I'll take your word for it that changing the content, and touching the file, will mean no caching. Thank you for your help.
–
RichardFeb 23 '12 at 1:27