You are here
Home > Tricks > Improve Website Performance Part-1

Improve Website Performance Part-1

Hello Friends, Today I am going to share how to improve your website performance and how to reduce website load time.

Today I am going to tell you about Leverage browser caching.

Leverage browser caching : – Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources from local disk rather than over the network, which reduces load time. To do this we can specify expiry for resource in server’s .htaccess file so that resources would be loaded from local disk instead of server till expiry time.

So here is the code which you can write in .htaccess file.

In the code you can see we can define different expiry time for different type of resources.

Here these four lines of codes are for image types

Here we are setting expiry for css files.

Here we setting expiry for html and pdf files.

Here we setting expiry for javascript files.

Above two lines of codes are for flash files and icon images.

This line sets expiry for all other resources.

There is another method also for setting expiry in .htaccess file

In .htaccess file # is used for comment so the first line is ignored here.

Above tells which files types to be chached.

Header set Cache-Control is setting headerĀ 
is defining expiry or max-age of resources and public just defining it is public



Thanks Please share if you like

Rajesh Kumar Sahanee
I am a passionate Java Developer and I like Computer Programming. I love to do some interesting experiments and listening music in my free time.