[英]PHP Caching Files (.htaccess)
I have the following code which I am using for my website. 我有以下用于我的网站的代码。 I would like to know if this code is correct in order for me to effectively cache me pages and files.
我想知道此代码是否正确,以便我有效地缓存页面和文件。 I have tried to use tools to check this but some say they don't see that I am caching.
我试图使用工具来检查这一点,但有人说他们看不到我正在缓存。
<ifModule mod_headers.c>
# 1 Month
<filesMatch ".(ico|gif|jpg|jpeg|png|pdf)$">
Header set Cache-Control "max-age=2419200"
</FilesMatch>
# 1 Week
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
# 1 Day
<filesMatch ".(htm|html)$">
Header set Cache-Control "max-age=86400"
</FilesMatch>
</ifModule>
Catching is the automatic mechanism of the browsers. 捕获是浏览器的自动机制。 When a page is loading, browser checks the cache for static files like js, css, images..., if they are not available browser will pus them into cache.
加载页面时,浏览器会在缓存中检查js,css,images等静态文件,如果不可用,浏览器会将它们拖入缓存。
To determine whether the file is cached or not, check the firebug console and clik on request link. 要确定文件是否已缓存,请检查Firebug控制台和按需单击链接。
here you can see information like 在这里您可以看到类似的信息
Accept-Ranges bytes
Cache-Control max-age=290304000, public
Content-Encoding gzip
Content-Length 2824
Content-Type application/javascript
Date Thu, 11 Jul 2013 10:15:06 GMT
Expires Fri, 12 Jul 2013 10:15:06 GMT
Last-Modified Thu, 03 Jan 2013 16:05:54 GMT
Server Apache
Vary Accept-Encoding,User-Agent
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.