Browse:  GUI  JavaScript  Linux  OpenBSD  PHP  Software  Web  Windows  Deals
 

Speeding up your web server with Cache Control
by Cory Rauch 2007-05-15 Category: Web-Performance

Using simple cache control directives you can speed up website by enabling better cache coverage when serving up pages. In this small tutorial I will go over one way of controlling caching using the cache-control directive.

Cache-Control?

The cache-control directive control the way cache in general is used and is found in the HTTP response header that comes from your webserver. This could be the browsers cache mechanism or this could be a cache proxy device. Where ever the cache control mechanism is implemented the cache-control directive tells it how to behave. With this directive you have the following options:

  • max-age - Specifies maximum amount of time that a transaction is considered fresh. This option is in seconds.
  • public - Makes content cacheable even if HTTP authentication is required.
  • private - Makes content cacheable only at the private (Usually browser cache) level not at the proxy or share cached mechanism level.
  • no-cache - Forces cache to check everytime if content has changed before using cached copy.
  • no-store - Makes content never cache
  • s-maxage - exactly like max-age except that it controls how a shared cache works (Ex. proxy).
  • must-revalidate - Instrcuts a cache mechanism to never deviate from the rules you specify since some cache mechanism may not strictly follow the cache instructions given.
  • proxy-revalidate - exactly like must-revalidate, except that it only modifies this behavior for proxy cache mechanism.

Looking at the above a standard blog website or company website should be fine with being aggressive if they are not serving up pages that change very often. Examples of sites that you would not want to be aggressive with caching would be secure pages, shopping pages, or pages that change frequently. An example Cache-Control directive (see your web server software docs for changing this setting):

Cache-Control: public, must-revalidate, max-age=86400

Other ImprovedSource Articles:
PHP v5.2 vs PHP v5.1
Why we need a Javascript-Based Database?
Cool Example of Java and Javascript working together

[ Back ]

ImprovedSource. Copyright 2007 + Contact Us + Home + Search + RSS Feed