[英]How to prevent PHP from caching using .htaccess
I am using following code for caching unknown as well as known files but I don't want PHP to be cached since it is causing problem with dynamic scripts. 我使用以下代码来缓存未知和已知文件,但我不希望缓存PHP,因为它导致动态脚本问题。 Note I don't want to add header to every PHP files to avoid it to be cached.
注意我不想为每个PHP文件添加标头以避免它被缓存。 Please suggest me if it is possible to prevent PHP from getting cached.
如果可以防止PHP被缓存,请建议我。
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 year"
</IfModule>
Should work in both .htaccess
and httpd.conf
应该在
.htaccess
和httpd.conf
<filesMatch "\.(html|htm|js|css)$">
FileETag None
<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>
</filesMatch>
Thanks it worked for me I just replaced customized it to 谢谢它对我有用我只是将其定制为
<filesMatch "\.(html|htm|php)$">
FileETag None
<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>
</filesMatch>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.