2012-03-28 175 views
1

我正在重做整个网站,浏览器正在使用处于相同URL的页面的缓存index.html如何防止浏览器使用旧的缓存的index.html?

这是.htaccess文件中的问题的一个目录中的全部内容:

<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> 

我在这里已经试过许多东西,但没有什么工作。这是我在标题中看到的全部内容:

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

没有请求标头或响应标头。

我在想我可以尝试一个RewriteRule来添加一些类似?28032012的东西,但我不知道如何尝试。

+0

难道你们就不能修改自己的index.html页面? http://stackoverflow.com/questions/748193/html-php-page-being-cached-client-side-when-it-should-not-be – 2012-03-28 19:59:37

+0

我可以,但我需要尽快推住这个网站可能。 – JDavis 2012-03-28 20:03:42

+0

它看起来像mod_expires根本不工作。您确定您已取消注释LoadModule expires_module模块/ mod_expires.so?在此之前,您应该清除浏览器的临时文件。我希望这有帮助。 – huangli 2012-03-29 02:23:44

回答

0

最后我用这个解决方案是所有重定向请求WWW非WWW请求。所以基本上,这种方法阻止了任何浏览器使用任何缓存资源,因为该网站的www版本不再存在。

0

我读过附加?版本= <%=版本%>有问题的文件名是缓存清除的好方法。您也可以尝试使用http标题“cache-control:max-age = 600”的更简单的解决方案,以便从服务器中提取10分钟或更长时间的页面上的任何内容。

0

你可以只追加/?到您网址的末尾。 例子:

www.google.com/?