apachecachingmod-rewritemod-expires

How do I prevent browsers from using an old cached index.html?


I'm redoing an entire website and the browser is using the cached index.html of pages that are at the same URL.

This is the entire content of the .htaccess file in one of the problem directories:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /products/

    # Remove 'index.html' from the URL for old links that include it.
    RewriteCond %{THE_REQUEST} ^.*\index\.html?\ HTTP/
    RewriteRule ^(.*)index\.html?$ "/products/$1" [R=301,L]

    # Use index.php for all requests.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ /products/index.php [L]
</IfModule>

# An atempt to tell the browser not to use a cached .html file.
ExpiresActive on
ExpiresByType text/html "access plus 0 seconds"

<FilesMatch "\.(html)$">
    Header set Cache-Control "private, must-revalidate"
</FilesMatch>

I've tried multiple things here, but nothing is working. This is all I see in the headers:

Request URL:http://www.example.com/products/
Request Method:GET
Status Code:200 OK (from cache)

There are no Request Headers or Response Headers.

I'm thinking I can maybe try a RewriteRule to add something like ?28032012 to the end of something, but I don't know how to even attempt that.


Solution

  • The solution I ended up using for this was to redirect all www requests to non www requests. So basically, this approach prevented any browsers from using any cached resources because the www version of the site no longer exists.