Spend Your Cache Wisely

Posted: November 16th, 2009
Filed under: Web Speed and Performance
Tags: , , ,

Spend Your Cache Wisely
Understanding Caching and Cache Control

Cache, not to be confused with “cash”, isn’t something to be spent down at the local market or every time someone loads your page for that matter. Effective cache control involves managing the freshness and frequency of your page loads. The basic idea behind caching is simple. Instead of wasting efforts by re-downloading a resource every time it is needed, keep a local copy, and reuse it for as long as it is still valid.

Every Web site, extranet, and intranet can benefit from cutting down on the amount of times the client needs to talk to the server to retrieve information; resulting in faster pages, reduced bandwidth load, and happier site visitors.

A Basic Example of How Caching Works

  1. A client makes an initial request of a set of resources (for example, an HTML page with linked images, script and style sheet files).
  2. The server responds by sending the requested resources, together with headers that tell how long each resource should be considered fresh.
  3. From this point on, subsequent requests for these same resources are mediated by a caching mechanism.
  4. As long as a given resource is still fresh, subsequent requests by the client for that resource are served from the cache, saving both the time and bandwidth of a round trip to the server.
  5. When the cache needs to display a resource that has expired or gone “stale,” it polls the server to find out if that resource has changed.
  6. In a perfect world, whenever a client does one of these checks, the resource it is asking about will in fact have been changed, and the server will respond with the newest version.

Given normal Web browsing conditions, a cached object will always load faster than an uncached one. Our testing shows that an uncached image can take 0.5 seconds to be verified by an origin server – multiply this lag by the number of images on a page, and your users could be waiting a very long time indeed without cache control.
Benefits of Caching

  • Eliminates unnecessary requests and bandwidth consumption
    Excessive conditional GET requests and 304 responses can bog down your server’s response time, making it take longer for your pages to load. When the server has to constantly serve up your content uncached it’s like your site is being seen for the very first time, every time.
  • Handle all requests with fewer server round-trips
    Improve browsing and page-rendering speed by avoiding network round-trips. Caching indisputably saves bandwidth and server resources because it reduces network traffic. It does this by reducing the number of round-trips between Web clients and Web servers.
  • Save money, save bandwidth
    Bandwidth can get costly, (an average dedicated server provider could charge up to $169 for 2TB/ month), having effective caching techniques in place will save you money. Also, keeping away from the dreaded “509 Bandwidth Limit Exceeded” error message is always a good thing.
  • Reduced page load time, Increased Visitor Retention
    If your pages are loading quickly then your visitors are much more likely to stay, and return. Site users place a premium on the ability to interact dynamically while still demanding the performance of static pages.

Caching your web sites with a product such as CacheRight will not only dramatically reduce your page load time and increase your visitor retention, but will also eliminate unnecessary requests and save on bandwidth consumption.

~ Port80

No Comments »

Leave a Reply