Your Ad Here

Saturday, November 5, 2011

How to Leverage Browser Caching

How to Leverage Browser Caching

Find your .htaccess file, open it with any text editor (Notepad for instance) and add these codes below. Then save it.
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType application/pdf “access 1 month”
ExpiresByType text/x-javascript “access 1 month”
ExpiresByType application/x-shockwave-flash “access 1 month”
ExpiresByType image/x-icon “access 1 year”
ExpiresDefault “access 2 days”
</IfModule>
## EXPIRES CACHING ##


What This Code Actually Does?

It will instruct the browser to cache different static resources like images, flash, PDF, JavaScript and icons for some specified period of time. You can also increase or decrease the values depending on your specific requirements. By configuring your web server to set caching headers for cacheable static resources, your site will appear to load much faster

No comments:

Post a Comment