技術(shù)員聯(lián)盟提供win764位系統(tǒng)下載,win10,win7,xp,裝機純凈版,64位旗艦版,綠色軟件,免費軟件下載基地!

當前位置:主頁 > 教程 > 服務器類 >

apache提示沒有設置 max-age or expires解決辦法

來源:技術(shù)員聯(lián)盟┆發(fā)布時間:2018-06-11 12:23┆點擊:

  大家看到這個就應該知道只要設置 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)站的的加載速度!