如何强制执行浏览器缓存?

时间:2011-12-06 11:30:26

标签: php http http-headers nginx

我有php脚本,用于提供脚本中的图像

我希望浏览器能够缓存图像,即使它来自api。

我已阅读帖子How to browser cache image from php

How to force a web browser to cache Images

要修改Expires标头,我已经尝试了但似乎没有运气 我手动

header('Content-Type : image/jpeg');
header('Content-Size : 2759' );
header('Cache-Control : public, max-age=2592000' );
header('Pragma : public' );
header('Expires: ' . date('r', time() + 30*24*60*60 ));

我输出的响应标题是:

Server: nginx/0.8.54
Date: Tue, 06 Dec 2011 11:20:17 GMT
Content-Type: image/jpeg
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/5.3.7-ZS5.5.0 ZendServer/5.0
Set-Cookie: ZDEDebuggerPresent=php,phtml,php3; path=/
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, public, max-age=2592000
Pragma: no-cache
Expires: Wed, 05 Dec 2012 18:20:17 +0700
Content-Size: 2759

如您所见,标题已被修改,但在缓存控制标题中,它仍然具有no-store和no-cache值,

是这个nginx配置的东西还是可以从php解决,以及如何?

提前谢谢你......

0 个答案:

没有答案
相关问题