(with )Wrapped css,js 缓存甚至无法使用 url

(with )Wrapped css,js cache is not working with even same url

Wrapper class 的工作原理

我创建了 php class 现在我可以这样做来将我所有的 css,js 组合在一起。它像这样工作 Wrap::set(array(file.css,file2.css,file3.css)) 然后我写了wrap::call_path 然后它开始生成 url 像这样 www.example.com/wrap_contects?path[]=file.css&path[]=file2.css&path[]=file3.css 然后在服务器端,我得到数组中的所有路径,然后我为每个路径尝试 file_get_content,之后我写了 echo all results.It put together all CSS,如果我写 JS 它将是 JS.

问题

问题是浏览器没有缓存这个 url。

备注

我考虑了所有安全问题,我创建了要发送的令牌 wrap_content.php 以防止文件获取内容对用户请求的任何文件起作用

我解决了这个问题,希望能帮助以后有同样问题的人解决这个问题 我将这些添加到 wrap_contents.php:

$cache_length=60*24*30;
$cache_expire_date = gmdate("D, d M Y H:i:s", time() + $cache_length);
    header("Expires: $cache_expire_date");
 header("Pragma: cache");
header("Cache-Control: max-age=2592000");

(if css) header("Content-type: text/css");

(if js) header('Content-Type: application/javascript');

这在 php 文件的响应上创建了 css,js 模拟器。