【问题标题】:Cache doesn't work, images are reloaded each time缓存不起作用,每次都重新加载图像
【发布时间】:2015-02-03 14:31:24
【问题描述】:

我在这里建立一个非常简单的页面:http://www.wordjackpot.com 我的问题仅出现在 Google Chrome 中,当我重新加载页面时,每次都重新加载图像,好像没有缓存一样,我不确定问题是来自我的代码还是来自 chrome,因为对于 stackoverflow.com 图像上的示例当我重新加载页面时有 http 代码 304。 那么我的问题是:我做错了什么?

谢谢。

【问题讨论】:

    标签: php html google-chrome browser-cache


    【解决方案1】:

    这些是您的返回标头...您明确告诉浏览器不要缓存。

    这将是一个 apache(网络服务器)设置。

    Accept-Ranges:bytes
    Accept-Ranges:bytes
    Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Connection:keep-alive
    Content-Length:4026
    Content-Type:image/png
    Date:Tue, 03 Feb 2015 14:33:44 GMT
    Pragma:no-cache
    Server:Apache
    Set-Cookie:300gp=R3396092545; path=/; expires=Tue, 03-Feb-2015 15:46:10 GMT
    X-Cacheable:Not cacheable: no-cache
    X-Geo:varn34.rbx5
    X-Geo-Port:1011
    X-Pad:avoid browser bug
    

    【讨论】:

    • 但是为什么呢?它是默认值吗?我必须通过 php 获得标题?
    • 好的,我找到了原因,我的环境在 OVH 配置中设置为“开发”并且它禁用了缓存。谢谢
    【解决方案2】:

    看看你的 HTTP 头,你没有缓存。

    【讨论】:

      猜你喜欢
      • 2023-03-18
      • 2016-02-29
      • 2021-12-05
      • 2018-05-29
      • 2015-12-13
      • 1970-01-01
      • 2021-08-17
      • 2011-12-15
      • 1970-01-01
      相关资源
      最近更新 更多