开发者

How to correctly cache images

开发者 https://www.devze.com 2023-01-02 05:54 出处:网络
I just installed Google\'s Page Speed plugin to Firebug, and everything looks good except for caching.I have set head开发者_JAVA百科ers to cache my JS and CSS files, but it says the images aren\'t bei

I just installed Google's Page Speed plugin to Firebug, and everything looks good except for caching. I have set head开发者_JAVA百科ers to cache my JS and CSS files, but it says the images aren't being cached. How can I make sure the images get cached for 30 days? These are static images, so I can't just add the headers with PHP like I did with the other files.


The page at http://www.askapache.com/htaccess/apache-speed-cache-control.html suggests something like this:

Add Cache-Control Headers

This goes in your root .htaccess file but if you have access to httpd.conf that is better.

This code uses the FilesMatch directive and the Header directive to add Cache-Control Headers to certain files.

# 480 weeks
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>


Put the following caching header:

Cache-Control: max-age=2592000

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号