php文件上的缓存和ModExpire出现大量问题 [英] massive Issue with Caching and ModExpire on php Files

查看:113
本文介绍了php文件上的缓存和ModExpire出现大量问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在全局.htaccess中使用以下内容,我确实在php文件上存在缓存和ModExpire的严重问题

I do have a massive Issue with Caching and ModExpire on php Files if i'am using following in my global .htaccess

<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresByType text/css "access plus 1 month"
 ExpiresByType text/javascript "access plus 1 month"
 ExpiresByType text/html "access plus 600 seconds"
 ExpiresByType application/javascript "access plus 1 month"
 ExpiresByType application/x-javascript "access plus 1 month"
 ExpiresByType application/xhtml-xml "access plus 600 seconds"
 ExpiresByType image/gif "access plus 1 month"
 ExpiresByType image/jpeg "access plus 1 month"
 ExpiresByType image/png "access plus 1 month"
 ExpiresByType image/x-icon "access plus 1 month"
</IfModule>
<ifmodule mod_headers.c>
 <filesmatch "\\.(ico|jpe?g|png|gif|swf)$">
  Header set Cache-Control "max-age=2592000, public"
 </filesmatch>
 <filesmatch "\\.(css)$">
  Header set Cache-Control "max-age=604800, public"
 </filesmatch>
 <filesmatch "\\.(js)$">
  Header set Cache-Control "max-age=216000, private"
 </filesmatch>
 <FilesMatch "\.(php)$">
    ExpiresActive Off
    Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
    Header set Pragma "no-cache"
</FilesMatch>
</ifmodule>

如果我运行的是php文件,该文件将返回值并保存某项内容。在MySQL数据库中,我必须重新加载两次或三遍,直到一切都正确完成。

If i am running a php file, which is returning a value and saving sth. in a MySQL DB, i have to reload twice or three times until all is done right.

我也曾在指定文件上尝试以下操作,但未成功
(如此处如何防止在Apache httpd(MAMP)中进行HTTP文件缓存

I also had tried the following on the specified file without success (as mentioned here How to prevent http file caching in Apache httpd (MAMP) )

<files folder/file.php>
 <ifModule mod_headers.c>
     Header unset ETag
     Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
     Header set Pragma "no-cache"
     Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
 </ifModule>
</files>

相同,如果我在文件夹htaccess中放入无高速缓存

same if i put no-cache inside the folders htaccess

推荐答案

为防止php文件缓存,请尝试删除 ExpiresByType application / xhtml-xml (适用于PHP)。

To prevent php files from caching try to remove ExpiresByType application/xhtml-xml, which is for PHP.

恕我直言,您也可以删除PHP文件的 FilesMatch

IMHO you can also remove FilesMatch for PHP files.

这篇关于php文件上的缓存和ModExpire出现大量问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆