【问题标题】:Problems caching images with php使用 php 缓存图像的问题
【发布时间】:2013-05-26 17:50:21
【问题描述】:

我有两个网站,一个用于访问者,一个用于内容。在第二个中,我正在尝试缓存图像,因为当您转到某个 url 时,总是会出现同样的事情。我不知道如何让我的浏览器(Chrome)缓存图像。这就是我得到的响应标题:

Cache-Control:public, max-age=1401497895
Connection:Keep-Alive
Content-Type:image/png
Date:Fri, 31 May 2013 00:58:15 GMT
Expires:Sat, 31 May 2014 00:58:15 +0000
Keep-Alive:timeout=5, max=100
Pragma:public
Server:Apache/2.2.22 (Ubuntu)
Transfer-Encoding:chunked
X-Powered-By:PHP/5.4.6-1ubuntu1.2

这是我的 php 设置标题:

header('Expires:Sat, 31 May 2014 00:58:15 +0000');
header('Cache-Control:public, max-age=1401497895');
header('Pragma:public');

我做错了什么??我想尽量减少图片加载时间。

此外,如果这很重要,我会从 CNAME 访问它们,尽管我在普通域中遇到了同样的问题。

【问题讨论】:

    标签: php google-chrome caching header http-headers


    【解决方案1】:

    为什么你将 max-age 设置得这么高? 您正试图将其设置为近 50 年!

    这应该可以,但我从未尝试过这么高的 max-age。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-22
      • 1970-01-01
      • 1970-01-01
      • 2018-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多