Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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文件的缓存和ModExpire存在大量问题_Php_.htaccess_Caching_Mod Expires - Fatal编程技术网

php文件的缓存和ModExpire存在大量问题

php文件的缓存和ModExpire存在大量问题,php,.htaccess,caching,mod-expires,Php,.htaccess,Caching,Mod Expires,如果我在我的global.htaccess中使用下面的内容,我确实会对php文件的缓存和ModExpire产生很大的问题 <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

如果我在我的global.htaccess中使用下面的内容,我确实会对php文件的缓存和ModExpire产生很大的问题

<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>

过期于
ExpiresByType文本/css“访问加1个月”
ExpiresByType文本/javascript“访问加1个月”
ExpiresByType text/html“访问加600秒”
ExpiresByType应用程序/javascript“访问加1个月”
ExpiresByType应用程序/x-javascript“访问加1个月”
ExpiresByType应用程序/xhtml xml“访问加600秒”
ExpiresByType image/gif“访问加1个月”
过期按类型图像/jpeg“访问加1个月”
ExpiresByType图像/png“访问加1个月”
ExpiresByType图像/x图标“访问加1个月”
标题集缓存控制“最大年龄=2592000,公共”
标题集缓存控制“最大年龄=604800,公共”
标题集缓存控制“最大年龄=216000,专用”
过期活动关闭
标题集缓存控制“专用、无缓存、无存储、代理重新验证、无转换”
标题集Pragma“无缓存”
如果我运行的是一个php文件,它返回一个值并将某物保存在MySQL数据库中,我必须重新加载两到三次,直到一切正常为止

我还在指定的文件上尝试了以下操作,但没有成功 (如本文所述)


标题未设置ETag
标题集缓存控制“最大年龄=0,无缓存,无存储,必须重新验证”
标题集Pragma“无缓存”
标题集过期“1984年1月11日星期三05:00:00 GMT”
同样,如果我在文件夹htaccess中没有缓存,那么这两行“ExpiresByType”可能就是这个问题的原因,正如您已经确定的那样

php文件返回text/html或application/xhtml xml类型的文档。因此,filematch*.php设置的头与前面的条目相矛盾。然后选择哪一个?我不知道


通常,PHP文件执行的结果很少应该被缓存。

为了防止PHP文件被缓存,请尝试删除用于PHP的
ExpiresByType应用程序/xhtml xml

您还可以删除PHP文件的
filematch

谢谢您的帮助!(闲逛)
<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>