Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 浏览器未缓存动态CSS-响应返回200 OK,而不是304 not Modified_Php_Css_Caching - Fatal编程技术网

Php 浏览器未缓存动态CSS-响应返回200 OK,而不是304 not Modified

Php 浏览器未缓存动态CSS-响应返回200 OK,而不是304 not Modified,php,css,caching,Php,Css,Caching,我有如下动态CSS文件: $Css = get_from($_u_6); /* do stuff and other things here... */ $expires = 60*60*24; header("Pragma: public"); header("Cache-Control: maxage=".$expires.", must-revalidate, public"); header('Expires: ' . gmdate('D, d M Y H:i:s', ti

我有如下动态CSS文件:

$Css = get_from($_u_6);



/* do stuff and other things here... */



$expires = 60*60*24; 
header("Pragma: public");
header("Cache-Control: maxage=".$expires.", must-revalidate, public");
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
header('Content-type: text/css');


echo $Css;
标题设置正确:

但是服务器总是用HTTP200OK(以及正确的内容)来响应,而不是用HTTP304(未修改)


我如何说服浏览器和服务器缓存这些动态css文件并发送304响应?

头告诉浏览器或缓存服务器在不从源服务器重新加载相同资源的情况下可以重复使用相同资源多长时间

如果您希望浏览器发出有条件的请求(例如,如果修改自:则使用
,如果不匹配:
,则使用
),则需要发送上次修改的
和/或
ETag:
头,您需要编写代码来测试这些头并生成适当的响应(
304
200


有关详细信息,请参阅。

RFC2616现已被、、和淘汰。