我正在改善Cakephp2网站之一的速度。
现在我需要设置一些标头过期并缓存内容。
但是在htaccess中的cakephp中,我必须放置我的代码。
并请提出任何不错的htaccess代码。
我试过了
#Expire Header
<FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresDefault "access plus 2 hours"
</FilesMatch>
但它不起作用,我也尝试了其他一些代码,但没有一个对我有用。是否缺少任何关键配置?
还有一件事,如果还有其他提高性能的技巧,请提出建议。
将以下代码添加到.htaccess文件
# cache images/pdf docs for 10 days
<FilesMatch "\.(ico|pdf|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=864000, public, must-revalidate"
Header unset Last-Modified
</FilesMatch>
# cache html/htm/xml/txt diles for 2 days
<FilesMatch "\.(html|htm|xml|txt|xsl)$">
Header set Cache-Control "max-age=7200, must-revalidate"
</FilesMatch>
更多信息http://tutorialpedia.org/tutorials/Apache+enable+file+caching+with+htaccess.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句