2

我正在重做整个网站,浏览器正在使用index.html相同 URL 的缓存页面。

这是.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的末尾添加类似的内容,但我什至不知道如何尝试。

4

4 回答 4

0

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

于 2012-03-28T19:59:02.830 回答
0

你可以附加 /? 到您的 URL 的末尾。例子:

www.google.com/?
于 2012-03-29T16:16:33.180 回答
0

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

于 2012-08-12T20:45:46.583 回答
0

这对我有用。

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0
</IfModule>

参考:https ://wp-mix.com/disable-caching-htaccess/

于 2017-10-22T23:33:24.980 回答