Menu bar

Saturday 21 June 2014

How to overcome Leverage Browser Caching?

What is LBC?

It is the way to remeber the resources that are loaded once on particular system.


Example:
It you visit http://www.mominiqbal.wordpress.com  say it as 'PAGE1', then you switch to new page say "PAGE2". Now from 'PAGE2'  if user switch to 'PAGE1' the resources will not be loaded again as it is already loaded earlier.


How to write LBC code?

To make Browser Caching Enable, we have to write the code in .htaccess file

<IfModule mod_expires.c>ExpiresActive On

#this will remeber the images for 1year.ExpiresByType image/jpg "access 1 year"ExpiresByType image/jpeg "access 1 year"ExpiresByType image/gif "access 1 year"ExpiresByType image/png "access 1 year"

#this will remeber the .css for 1 month.ExpiresByType text/css "access 1 month"

#this will remember the .html for 1 month.ExpiresByType text/html "access 1 month"

#this will remeber the .pdf for 1 month.ExpiresByType application/pdf "access 1 month"ExpiresByType text/x-javascript "access 1 month"

#this will remeber the flash file for 1 monthExpiresByType application/x-shockwave-flash "access 1 month"

#this will remeber the favicon for 1 monthExpiresByType image/x-icon "access 1 year"

#if access is not mention then default is this.ExpiresDefault "access 1 month"</IfModule>

No comments: