在.htaccess中禁用后未禁用浏览器缓存

时间:2021-04-16 作者:Firouziam

我的一个wordpress网站出现了一个奇怪的问题。问题是,当一个网页呈现一次时,编辑该页面之后将不会生效。因此,无论您刷新页面多少次(使用F5),它都会显示旧版本。但按ctrl+f5可以解决问题,并显示页面的当前版本。我不使用缓存插件。我已在中禁用浏览器缓存。htaccess使用以下代码。

我不知道还能做些什么来解决这个问题。非常感谢您的任何建议。

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

<FilesMatch "\\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    </IfModule>
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    </IfModule>
</FilesMatch>
编辑1:

Http响应头(F5)

Request URL: https://abobargh.ir/compare/
Request Method: GET
Status Code: 200  (from service worker)
Referrer Policy: strict-origin-when-cross-origin
content-encoding: br
content-type: text/html; charset=UTF-8
date: Fri, 16 Apr 2021 15:52:30 GMT
link: <https://abobargh.ir/wp-json/>; rel="https://api.w.org/", <https://abobargh.ir/wp-json/wp/v2/pages/18>; rel="alternate"; type="application/json", <https://abobargh.ir/?p=18>; rel=shortlink
vary: Accept-Encoding
Provisional headers are shown. Disable cache to see full headers.
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36
Http响应标头(Ctrl+F5)

Request URL: https://abobargh.ir/compare/
Request Method: GET
Status Code: 200 
Remote Address: 89.39.208.172:443
Referrer Policy: strict-origin-when-cross-origin
cache-control: public, max-age=2592000
content-encoding: br
content-type: text/html; charset=UTF-8
date: Fri, 16 Apr 2021 18:34:35 GMT
expires: Sun, 16 May 2021 18:34:35 GMT
link: <https://abobargh.ir/wp-json/>; rel="https://api.w.org/"
link: <https://abobargh.ir/wp-json/wp/v2/pages/18>; rel="alternate"; type="application/json"
link: <https://abobargh.ir/?p=18>; rel=shortlink
vary: Accept-Encoding
:authority: abobargh.ir
:method: GET
:path: /compare/
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-GB,en;q=0.9
cache-control: no-cache
cookie: irk-compare-list=18449%2C19458%2C41925
pragma: no-cache
sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"
sec-ch-ua-mobile: ?0
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: none
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36

1 个回复
SO网友:Firouziam

经过几天的努力,我终于克服了这个问题,以下是我采取的步骤:

重置。htaccess to default values(没有运气)

  • 将上述值添加到。htaccess为了禁用杠杆浏览器缓存(运气不好),联系了我的主机提供商,要求他们禁用我主机上的任何潜在缓存策略(他们回答没有!)
  • 禁用了所有插件,清除了浏览器缓存,一切正常。所以其中一个插件有问题

    这就是我克服这个愚蠢而恼人的问题的旅程。我一个接一个地分享了这些步骤,以防将来对某人有所帮助。希望它会有用。谢谢你的评论。

    编辑:

    MrWhite:

    但是,正如您从HTTP响应头中看到的那样;插件;“没有重新启用传统”;浏览器缓存;。但这很可能是对;服务人员-在浏览器中运行的JavaScript负责缓存自己的内容(超出正常浏览器缓存的视频),通常用于;“脱机”;查看(例如forPWAs)。

  • 相关推荐

    将未登录用户重定向到.htaccess文件中的自定义注册/登录页面的规则

    我正在尝试从"/purchaseads/purchase.php" 自定义注册/登录url"/purchaseads/registrationurl"在wordpress网站上。不幸的是,当访问url时"/purchaseads/purchase.php" 即使是未登录的用户,也不会更改任何内容,不会重定向到自定义注册/登录表单。这个我使用的httaccess代码段如下RewriteCond %{HTTP_COOKIE} !.*wordpress