The Last Modifies header field indicate the date and time at which origin server believe your file was last modified.
Last-Modified = “Last-Modified” “:” HTTP-date
Last-Modified: Tue, 15 Nov 1994 12:45:26 GMT
When any user comes first time at that time your browser will make number of HTTP requsets to download all the contents. With Expire Headers you can make those contents cachable for certain (defined) time, so for next it will load the content from the cache instead of making the request to server content.
Expire header should be applied to all static components including CSS, js, Flash files.
# Set Expire Date to 15 Apr 2011
Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT"
# You can set Fixed time also
ExpiresDefault A300 # 5 Min
ExpiresDefault A2700 # 45 Min
ExpiresDefault A3600 # 1 Hour
ExpiresDefault A54000 # 15 Hour
ExpiresDefault A86400 # 1 Day
ExpiresDefault A518400 # 6 Days
ExpiresDefault A604800 # 1 Week
ExpiresDefault A1814400 # 3 Week
ExpiresDefault A2419200 # 1 Month
ExpiresDefault A26611200 # 11 Month
ExpiresDefault A29030400 # 1 year , Never Expire
# You can use any of the time limit based on your content refresh time.
Be sure that you should not catch the content for more that one year, as its violets the RFC guidelines for Catching the content in browser.
Have you ever looked at Browser Response Header? You will see one thing which is eTag, Then What is this eTag?
eTag is the Entity Tags, an Unique identifier associated with the each resource of the site.
To turn of the eTag you can use below code in .htaccess fie.
When ever your browser make the request to the any resource, first it will check the eTag and if-match header to check the resource is modified or not since last it was cache.
You can see the Browser Response headers using Firebug Net Panel, Please have a look at the below image for the reference.
From my point of view you should do below to make the proper caching.
Use the expire header by setting the far expiration date.
If you have used the Expire Header then you should disable the Last Modified Header, This is because, some browsers are blocking the Last Modified Header if Expire Header is available.
If you have used the Expire Header then you should disable the eTag , reason is same as for Last Modified.
Let me know your suggestion by commenting here.
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash