Expire Header | Cache-Control Header | Best Practice to Speed up your website

  • Avinash
  • 6
  • Aug 11, 2010
  • Web Development

There are two aspects to this rule:

  • For static components: implement “Never expire” policy by setting far future Expires header
  • For dynamic components: use an appropriate Cache-Control header to help the browser with conditional requests

For rich interface websites for first-time visitor to your page may have to make several HTTP requests, but by using the Expires header you make those components cacheable. This avoids unnecessary HTTP requests on subsequent page views. Expires headers are most often used with images, but they should be used on all components including scripts, stylesheets, and Flash components.

Browsers user cache to reduce the number and size of the HTTP requests and making the page loads faster. A we server uses expire header in HTTP request to tell the client ( Browser ) how long a component can be cached.

Expires: Thu, 15 Apr 2010 20:00:00 GMT
Expires: Thu, 15 Apr 2010 20:00:00 GMT

Above line will tell browser to cache the component in the HTTP request to until 15 April 2010.
If your server is Apache, use the ExpiresDefault directive to set an expiration date relative to the current date. This example of the ExpiresDefault directive sets the Expires date 10 years out from the time of the request.

ExpiresDefault "access plus 10 years"
ExpiresDefault "access plus 10 years"

This trick works only if user have already visited your site once. This has no effect in performance if the user if visiting your website for first time using empty cache.

By using a far future Expires header, you increase the number of components that are cached by the browser and re-used on subsequent page views without sending a single byte over the user’s Internet connection.

Source : Yahoo Tips

Related Posts

Written by Avinash

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:

  • Pingback: Tips to speed up website and get high ranking in ySlow | Xpert Developer

  • student

    Valuable info. Lucky me I found your site by accident, I bookmarked it.

  • Fausto Zerkle

    I really appreciate what you write about here. I try and check your blog every day so keep up the good work!

  • http://my.opera.com/dianadhowell/blog/ Howard Guelpa

    this really is def. 1 of the greater subject matter

  • http://www.fishfinder-review.com Karen Allard

    I would like to stay in touch, What is your facebook page?

  • http://genericwpthemes.com Woddy

    Nice post and this fill someone in on helped me alot in my college assignement. Thank you on your information.