views:

19

answers:

1

I need to make sure when the user hits back with, for example, the mouse, the browser doesn't instantly load the page from the cache and instead runs the associated code again.

This is what my .htaccess looks like. It appears to be just Firefox that is ignoring the cache settings.

<IfModule mod_expires.c>
    ExpiresActive On
#   ExpiresDefault A2630000
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
    ExpiresByType image/ico "access plus 1 year"
    ExpiresByType image/gif A2630000
    ExpiresByType image/jpeg A2630000
    ExpiresByType image/png A2630000
    ExpiresByType application/x-javascript M2630000
    ExpiresByType text/css M2630000
</IfModule>

<IfModule mod_headers.c>
    Header set Cache-Control "public"
</IfModule>

#make php scripts uncacheable
<FilesMatch "php">
    Header unset Cache-Control:
    Header append Cache-Control: "no-cache, must-revalidate"
</FilesMatch>

SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
+1  A: 

A shot in the dark, but the header names aren't supposed to have colons. Try

<FilesMatch "\.php$">
    Header set Cache-Control "no-cache, must-revalidate"
</FilesMatch>

(I also changed the FilesMatch condition to match only php extensions, and removed the unset/append - set should do the same job.

Pekka
Thanks for your answer. I had copied that part from a site found in a Google search and had no idea if it was the correct way to do it or not. However, it's still not working in Firefox. Firebug does indeed confirm that the headers are set but it also says "200 (cache)" under the Status column in PageSpeed, suggesting that the resource came from the cache regardless?
bcmcfc
@bcm 200 (cache) means that no request was made to the server at all. Try using this header value: `no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0`
Pekka
bcmcfc