Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Related: Apache: How can I force the browser to reload CSS files?

I'm building an xml page (on an apache2) that is supposed to be translated to xhtml by the browser, so my server also serves a main.xslt which is used as stylesheet by the xml file, similar to the scenario with the css files in the linked question.

However, none of tricks provided in either that answer, nor some issues on SO solve the issue for Opera. While Firefox responds to F5 by fetching not only the xml file but also the xslt file, Opera only reloads the xml file. I tried both, setting the Last-Modified HTTP header via an .htaccess file and using the expires module of apache2.

This is what my .htaccess looks right now:

AddType text/xsl;charset=utf-8 .xslt
ExpiresByType text/xsl "modification plus 1 second"
Header set Last-Modified "Wed, 08 Jan 2000 23:11:55 GMT"
#Header set Last-Modified "Wed, 08 Jan 2020 23:11:55 GMT"

If I open the xsl myself and manually reload it, the xml presentation is updated as well, but this is tedious for development.

Note: There is no php or any kind of scripting involved. Everything is static.

share|improve this question
    
You probably don't want to hardcode the Last Modified date to a set value. You're telling the browser "hey, this is the same file you got last time, it's not changed for 12 years". –  Tim Fountain Mar 31 '12 at 11:25
    
@TimFountain: I tried to set it to both a date way in the past and a day way in the future. No difference. Also, keep in mind is mainly for development, not production. –  bitmask Mar 31 '12 at 13:32
    
@TimFountain point was that you needed to set it the current time, since the first time the browser downloads it it will keep the modified information and see that it is the same as last time and not update it. –  Joshua Drake Apr 9 '12 at 16:56
    
My point was that Last Modified helps browser know when they can use their cached version of a resource. If you want the browser to always fetch a fresh copy, you probably don't want to use Last Modified at all. –  Tim Fountain Apr 10 '12 at 17:46
    
@TimFountain: I only introduced the Last Modified rule, because the browser was never reloading the file, no matter what. Eventually I would, of course, prefer to have the normal semantics of "file changed <=> reload", but right now I cannot convince the browser to reload it at all (unless I manually clear the cache). –  bitmask Apr 10 '12 at 22:05

2 Answers 2

According to http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html#100_Prevent_Files_cached, this should do the trick:

Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
share|improve this answer

You can just append a random querystring file.css?version=may15-2012 and have that data change. The browser will treat the querystring as a new file and download the CSS / JS / Image file again.

share|improve this answer
1  
Dates are nice, version numbers a bit better I think so people don't think a file is out of date. epoch is also an option to add the current date and time in a format not really recognized by most people. –  Anagio Jul 26 '12 at 11:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.