简体   繁体   English

htaccess不能缓存php文件吗?

[英]htaccess not caching php file?

I have the following rules in the htaccess file: htaccess文件中有以下规则:

<IfModule mod_headers.c>
  <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
    Header set Cache-Control "max-age=62, public"
  </FilesMatch>
</IfModule>

and in my php file(test.php) i have the following code 在我的php文件(test.php)中,我有以下代码

echo "time: ".time();

So now when i request the file i am seeing that the cache control is applied but the server is not providing the cache version. 因此,现在当我请求文件时,我看到已应用缓存控件,但服务器未提供缓存版本。

For the record, i am using xampp environment. 作为记录,我正在使用xampp环境。

Setting a Cache-Control header in a response, as you're doing here, only directs clients to cache the page. 如您在此处所做的那样,在响应中设置Cache-Control标头只会引导客户端缓存页面。 It doesn't trigger any server-side caching. 它不会触发任何服务器端缓存。

(Additionally, clicking the reload button in a browser will ignore the Cache-Control header and always request the content from the server again. That's the whole point of reloading the page, after all!) (另外,在浏览器中单击“重新加载”按钮将忽略Cache-Control标头,并始终再次从服务器请求内容。毕竟,这就是重新加载页面的全部目的!)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM