我使用下面的代码来获取网站的HTTP标头。检查网站是否启用缓存或不从HTTP头
<?php
$url = "http://www.google.com/";
$headers = get_headers($url);
$code = $headers[0];
print_r($headers);
?>
上面的代码显示输出:
Array (
[0] => HTTP/1.0 302 Found
[1] => Cache-Control: private
[2] => Content-Type: text/html; charset=UTF-8
[3] => Location: http://www.google.co.in/?gfe_rd=cr&ei=6Ge_VvG0JKTv8wekkIegCA
[4] => Content-Length: 261
[5] => Date: Sat, 13 Feb 2016 17:29:12 GMT
[6] => HTTP/1.0 200 OK
[7] => Date: Sat, 13 Feb 2016 17:29:12 GMT
[8] => Expires: -1
[9] => Cache-Control: private, max-age=0
[10] => Content-Type: text/html; charset=ISO-8859-1
[11] => P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."
[12] => Server: gws
[13] => X-XSS-Protection: 1; mode=block
[14] => X-Frame-Options: SAMEORIGIN
[15] => Set-Cookie: NID=76=ap8f4I3nvVUaV7rYQYL88Un1P5ctbb-SPDcn7Zq1UYXkqb-mcQUD9gtrJsn2v67hUiTVT62xDebimSvxL__EzsQrf9Er_cUP9wnv7NVJcS0FgOEj0enKgzu0o6zKOyBF; expires=Sun, 14-Aug-2016 17:29:12 GMT; path=/; domain=.google.co.in; HttpOnly
[16] => Accept-Ranges: none
[17] => Vary: Accept-Encoding
)
我怎么能知道这个网站是否已经从这个头启用与否浏览器缓存?