如何在CSS,JS和图片上设置过期时间 [英] How do i set expiration on CSS, JS and Images
本文介绍了如何在CSS,JS和图片上设置过期时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我最近在Firebug上使用Pagespeed插件分析了我的网站.它建议我设置CSS,JS和图像文件的有效期.
I have recently analysed my website with pagespeed addon on firebug. It suggested me to set expiration on CSS, JS and image files.
我想知道我该怎么做?
推荐答案
这是我运行PageSpeed插件时用来修复完全相同的东西的
This is the one I use to fix the exact same thing when I ran the PageSpeed Addon:
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
这进入您的.htaccess文件.
This goes into your .htaccess file.
在此页面上阅读有关如何设置其他文件类型的缓存和/或更改缓存长度的更多信息:
Read up on this page for more information about how to set cache for additional file types and/or change the cache length:
http://www.askapache.com/htaccess/apache- speed-cache-control.html
这篇关于如何在CSS,JS和图片上设置过期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文