Access logs | IBM HTTP Server Plug-in


Expiration of static content


+

Search Tips   |   Advanced Search

 

The module mod_expires can be used to enable expiration times for static content. This is typically done for static content that is likely to be updated. For example, a downloadable PDF file with terms and conditions for using your online store is updated every time the terms and conditions change.

To prevent the client browser from loading the file from its cache after an update, you can set expiration times at file, directory, virtual host, or server level. You can also set default expiration times for file types. The expiration time is passed back as an HTTP header with the response to a request for a static file, causing the client browser to reload the file from the server after the expiration time has passed even if the file is still being cached.

You should not use short expiration times on static files that are usually not changing, for example, product images. Only use expiration time on files that are going to be updated.

To...

  1. Load and activate the module
  2. Configure images in the nocache directory for no caching (w/expiration of 1 second after client access time)
  3. Configure PDF files in the same directory to expire one week after the file modification time

...use...

LoadModule expires_module     libexec/mod_expires.so
...
ExpiresActive On
...

<Directory /IBM/WAS/AppServer/profiles/demo/installedApps/WC_demo_cell/WC_demo.ear/Stores.war/ConsumerDirect/images/nocache>

  <FilesMatch "\.(gif|jpg|png)">

    order allow,deny
    allow from all

    ### Expire one second after client access time
    ExpiresDefault A1

  </FilesMatch>

  <FilesMatch "\.pdf">

    order allow,deny
    allow from all

    ### Expire one week after modification time
    ExpiresDefault M604800
  </FilesMatch>

</Directory>