【问题标题】:How to force to refresh a web page如何强制刷新网页
【发布时间】:2015-11-25 13:27:56
【问题描述】:

我正在使用网络服务器。

之前:有一个网站。 “domain.com/”重定向到“domain.com/index.html”(逻辑),该页面重定向到“domain.com/en/index.html”,标签为: "meta http-equiv="refresh" content="0;url=en/index.html""

现在:有一个 Wordpress(我安装了它),没有 index.html,但有一个 index.php。

问题:当我想访问“domain.com”时,我被重定向到 domain.com/en/index.html。

我知道这是一个缓存问题,但如何禁用此缓存。重定向?

我找到了关于 htaccess 的解决方案(添加 Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" )但它不起作用。

在网络分析仪下方

【问题讨论】:

    标签: php html wordpress .htaccess redirect


    【解决方案1】:

    如果重定向是 301,那么您需要使用“忘记此站点”,因为 301 是永久重定向,将保存在浏览器缓存中。简单的页面重新加载不会刷新缓存。

    我经常偶然发现这种情况:

    foo.com使用301重定向到bar.com,当你第一次访问foo.com时,浏览器会记住这个重定向,下次访问foo.com时,浏览器甚至不会连接到foo.com ,而是直接连接到bar.com

    @编辑: 这似乎是一个 302 重定向。 只需编辑yourwebsite.com/index.html 并将meta http-equiv="refresh" content="0;url=en/index.html 更改为meta http-equiv="refresh" content="0;url=en/index.php。基本上,在刷新元数据中将扩展名从 .html 更改为 .php。

    【讨论】:

    • 哦不,这不是 301,只是一个带有这个标签的页面:“meta http-equiv="refresh" content="0;url=en/index.html"
    • 是的,就是这样 ;) 但我想我可以禁用它,因为 html 在用户浏览器缓存中:/
    【解决方案2】:

    我猜这实际上是 DirectoryIndex 问题,而不是缓存问题。

    如果您查看the documentation,您会看到该指令采用 Apache 尝试按顺序定位的索引列表。因此,您可以通过将index.php 移动到列表的前面来强制优先级

    DirectoryIndex index.php index.html
    

    【讨论】:

    • 感谢您的回复。但是当我使用禁用缓存时,网站会显示 wordpress (-> index.php)。 DirectoryIndex 是个好主意,但我没有访问 apache 配置...我尝试将它添加到 .htaccess 但它不起作用。
    猜你喜欢
    • 2014-01-11
    • 2010-11-15
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 2021-05-24
    相关资源
    最近更新 更多