Image caching in WordPress
Most WordPress themes use a number of images, js and other static contents. By default these static content are not cached so they are downloaded again on each request. This makes web page response very slow.
This can be improved by using browser cache. To enable browser cache you need do as below
1 – Create .htaccess file in wp-content folder
2- Put following code in above file
<ifmodule mod_expires.c>
<filesmatch “\.(jpg|JPG|gif|GIF|png|css|ico|js)$”>
ExpiresActive on
ExpiresDefault “access plus 120 day”
</filesmatch>
</ifmodule>
This will tell browser to use images and js files from local cache for 120 days. Doing this will significantly reduce number of http request sent from each page. You can verify the effect using YSlow or PageSpeed.
You can find more techniques in my Top 3 Guidelines for Performance post.
hey thankx for sharing information. Its really works I have used it in one of my website, it really takes off some time by caching the images and other specified media contents.
I am using following in my /htaccess file.
Header set Expires “Mon, 20 Apr 2012 23:30:00 GMT”
Header append Cache-Control “public”
I am setting Expires limit to “Mon, 20 Apr 2012 23:30:00 GMT”
Well If we are talking to improve the speed of web site then I aill also suggest to use sub domains for the media files. It simply minimize the dns look ups and that will create major effect in speed. The best example of this technique is google maps.
By this technique we can simply minimize Round-trip time (RTT).
Thanks
Roy
after inserted .htaccess file with this code, my template doesn’t load
Strange, are you getting 505 error or you site is being loaded and only images are not there. Please be sure to place the code at right place and track for any errors because code is working on many sites.