Website Building Question: How do You Handle the Browser Caching Issue?

briptech

Power Member
Joined
Apr 4, 2011
Messages
567
Reaction score
223
By using several PAGE SPEED LOAD analyzing tools (last but not least the YSlow add-on for Firebug) I noticed that one of main concern of most of my websites is the "Leverage browser caching" issue.

That specifical issue is explained by the output of the tool:
"Reduce the load times of pages by storing commonly used files from your website on your visitors browser."

The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:

http://www.mysite.com/wp-content/themes/theme-name/css/stylename.css (expiration not specified)
http://www.mysite.com/wp-content/themes/theme-name/images/icons-header.png (expiration not specified)
http://www.mysite.com/wp-content/themes/theme-name/images/background_1.jpg (expiration not specified)

AND SO ON... The list goes on for at least 30+ resources.

The strange thing is that if I run the same tool on SitePoint.com or similar trusted site I get the same kind of error.

What do you think guys?
 
Add expires header in your .htaccess file. A first-time visitor to your page will make several HTTP requests to download all your sites files, but using the expires headers you make those files cacheable. This avoids unnecessary HTTP requests on subsequent page views. To do it add these lines to your .htaccess file:
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604800 seconds"
ExpiresByType text/javascript "access plus 216000 seconds"
ExpiresByType application/x-javascript "access plus 216000 seconds"
</ifModule>
You can increase the seconds period.
Hope this will help. :)
 
Back
Top