It is often desirable to set long cache times for static content and you may also want to ensure that certain other files or URIs are never cached. Unfortunately ATG does not provide a mechanism for tuning the cache headers.
I have created a new ATG Module which allows you to easily adjust cache header times based on mime-types and URIs, including parent directories. You can download it here: DSCacheControl ATG Cache Header Control Module.
I have built and tested it using ATG 7.1 I will be releasing one for ATG 2007.1 in a bit, which may be based on a Servlet Filter instead, but I haven’t decided yet. This one may work on ATG 2007.1, I haven’t been able to test it yet.
It is very simple, with two classes: a pipeline servlet and a custom comparator, and two config files: the pipeline servlet’s configuration and an Initial.properties to start the servlet. The source code is included in the module.
It allows you to control the cache time used to build the cache related response headers based on the requested asset’s mime-type and URI location. It has an order of precedence of a default setting of 0 seconds (do not cache at all), then the mime-type settings are used, and then the URICacheMap is examined to find the most specific entry which is the specific URI or a parent directory. This should allow you to setup basic settings, and override them for specific directories or files as needed.
Here are some example config settings to give you an idea:
To install it, simply download the zip file, unzip it, copy the module into your ATG 7.1 root directory and add the module to the list of DYNAMO_MODULES in your environment.sh (or add it using the -m option on the command line when you start ATG). You will likely want to override the default configuration. The .properties file is heavily commented and should be simple to understand. You can edit it within the module if you like, although of course the better approach is to set your cache settings in your application module or in localconfig, depending.
If you try it, please give me your feedback. If you enhance it, please share the code back with me.