PHP“Cache-Control”头和Nginx

时间:2015-07-16 13:25:42

标签: php nginx cache-control

获得了php文件:

<?
$maxAge = 2592000;
header ("Content-Type: application/x-javascript; charset=utf-8");
header ("Last-Modified: Thu, 19 Jul 2012 12:56:03 GMT");
header ("Expires: " . gmdate ('D, d M Y H:i:s \G\M\T', time () + $maxAge));
header ("Cache-Control: max-age=" . $maxAge);

Headers,当使用本地apache服务器时

$curl -I http://localhost/js/js.php
HTTP/1.1 200 OK
Date: Thu, 16 Jul 2015 12:07:47 GMT
Server: Apache/2.2.14 (Unix) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
X-Powered-By: PHP/5.3.1
Last-Modified: Thu, 19 Jul 2012 12:56:03 GMT
Expires: Sat, 15 Aug 2015 12:07:47 GMT
Cache-Control: max-age=2592000
Content-Type: application/x-javascript; charset=utf-8

在网上查看时(Nginx):

$ curl -I http://***/js/js.php
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 16 Jul 2015 12:15:21 GMT
Content-Type: application/x-javascript; charset=utf-8
Connection: keep-alive
Keep-Alive: timeout=10
X-Powered-By: PHP/5.3.8
Last-Modified: Thu, 19 Jul 2012 12:56:03 GMT
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache

如何从PHP标头启用Cache-Control?

0 个答案:

没有答案