大家看到這個就應該知道只要設置 max-age or expires就行了。下面說的方法是在設置apache下的方法:
產(chǎn)生要開啟
代碼如下LoadModule headers_module modules/mod_headers.so
然后再在.htaccess文件下面寫上
代碼如下<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=18000, public, must-revalidate"
</FilesMatch>
<FilesMatch "\.(html|htm|php|shtml)$">
Header set Cache-Control "max-age=3600, must-revalidate"
</FilesMatch>
</IfModule>
如果沒有開啟“mod_headers”模塊,而又沒有加“”條件判斷的話,網(wǎng)站就會出錯!
設置 max-age or expires是用來緩存靜態(tài)文件,提升網(wǎng)站的的加載速度!