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
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.
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"
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.
0 comments:
Post a Comment