html 静态资源缓存时间,.htaccess设置静态资源缓存(即浏览器缓存)
在HTTP標頭中為靜態資源設置過期日期或最長存在時間,可指示瀏覽器從本地磁盤中加載以前下載的資源,而不是通過網絡加載。這樣,
網站加載速度會更快.
下面的代碼都需要放到.htaccess中才能生效.
推薦設置過期時間為一個月, 即: max-age=2592000.
通過FilesMatch設置
Header set
Cache-Control "max-age=2592000"
通過mod_expires.c設置
ExpiresActive On
ExpiresDefault "access
plus 1 months"
ExpiresByType text/html "access plus 1
months"
ExpiresByType image/gif "access plus 1 months"
ExpiresByType
image/jpeg "access plus 2 months"
ExpiresByType application/x-shockwave-flash
"access plus 2 months"
ExpiresByType application/x-javascript "access plus 2
months"
如需針對具體的資源類型需要這樣:
ExpiresByType image/gif "access plus 5 hours 3 minutes"
原文:http://www.cnblogs.com/jsonzheng/p/3782215.html
總結
以上是生活随笔為你收集整理的html 静态资源缓存时间,.htaccess设置静态资源缓存(即浏览器缓存)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android ge模拟器,在Andro
- 下一篇: 2017年html5行业报告,云适配发布