Tellme Studio

Home MyStudio About Tellme
Configuring Apache 1.3 to use mod_expires

This document explains how to configure Apache 1.3x to send the Expires header using the mod_expires.c module.

To put the examples included in this document in context, please review the caching strategy described in Effective Use of Caching to Boost VoiceXML Application Performance.

Before you can configure Apache to output the Expires header with your content, you need to verify that the standard mod_expires module is installed. To see what Apache modules are currently installed, run the following command on the server running Apache:

% httpd -l

If mod_expires.c is not listed, consult your Apache distribution for instructions on how to enable the module.

The most straightforward and high performance way to control the caching behavior of your documents is to edit your Apache configuration file (httpd.conf). Use the IfModule, LocationMatch, ExpiresActive, and ExpiresDefault directives to add the appropriate HTTP header to a file or directory of files.

In the following example, the first set of directives ensures that the Expires header is not sent for any content by default. The second set of directives configures Apache to send Expires and Cache-Control headers when content in any one of the six directories (plus any contained subdirectories) specified by the LocationMatch directive is requested. The content expires an hour after the request.

<Location />
   <IfModule mod_expires.c>
      ExpiresActive off
   </IfModule>
</Location>


<IfModule mod_expires.c>
   <LocationMatch "/2002-03-23-1100/(vui|js|signin|quotes|portfolio|balances)/">
       ExpiresActive on
       ExpiresDefault "access plus 1 hour"
   </Location>
</IfModule>

The following example ensures that all files with a .wav extension are cached for one hour from the time they are requested.

<IfModule mod_expires.c>
  <FilesMatch "\.wav$">
       ExpiresActive on
       ExpiresDefault "access plus 1 hour"
   </FilesMatch>
</IfModule>

Another mechanism for specifying expires headers is the .htaccess file. If .htaccess files are enabled, you can add the file to a directory to set expiration policies on the content in that directory and any contained subdirectories using the same syntax as described in the previous section.

Before resorting to .htaccess files, however, you should discuss the performance impact with your Web server administrator. Each time a file is requested from a directory containing an .htaccess file, Apache must process that .htaccess file as well as every .htaccess file that exists up the directory chain to the document root. The performance penalty can be signficant.

An ETag is an HTTP response header returned by an HTTP/1.1 compliant Web server such as Apache 1.3x. By default, Apache calculates an ETag for a requested file using a combination of the file's location in the file system (I-Node number on Unix systems), its modification time, and its size. The proxy caches running on the Tellme Voice Application Network use the value of the ETag header in conjunction with the If-None-Match request header when validating an object with an origin server.

Because the ETag is calculated using the file's I-Node, and an I-Node is machine-specific, administrators of Web server farms will experience unexpected requests if the ETag differs from machine to machine.

To work around this issue, use the FileETag directive to configure your Apache server to use only the file modification time and file size when calculating the ETag.

The following example configures Apache to only use the modification time (MTime) and size (Size) when calculating the ETag for any file contained in the /usr/local/httpd/htdocs directory or a subdirectory.

<Directory /usr/local/httpd/htdocs>
   FileETag MTime Size
</Directory>

Tellme Networks, Inc.Terms of ServicePrivacy PolicyGeneral Disclaimers