用PHP缓存图像的问题

时间:2013-05-31 01:03:52

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

我有两个网站,一个是访问者,一个是内容。在第二个,我正在尝试缓存图像,因为当你去某个网址时,同样的事情总会在那里。我无法弄清楚如何让我的浏览器(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访问它们,尽管我遇到了与普通域相同的问题。

1 个答案:

答案 0 :(得分:0)

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

这应该可行,但我从未尝试过如此高的最大年龄。