Controlling what is cached
Caching Proxy offers several filtering methods to control which files, documents, and other objects are cached
- URL-based caching filters
- Query response caching
- Caching locally served files
- Partial URL-based caching
- Caching files that are based on part of the request URL
- Caching dynamically generated files
Configuring URL-based caching filters
The proxy server can be configured to compare requests to a URL template to determine whether a file is cached. This feature is configured by setting templates for requests whose files are always cached, and separate templates for requests whose files must never be cached. Multiple templates can be used.
A similar system is used to enable query response caching.
To set URL caching filters in the Configuration and Administration forms, use the Cache Configuration –> Cache Behavior: Cache filtering by URL field. Use this section to specify URLs whose files are always cached, or to specify URLs whose files are never cached. To specify two lists, one of files to always cache and one of files to never cache, create one list and then click Submit before creating the other list.
Caching query responses
The responses that are returned from queries (URL requests that contain a question mark) can be cached by using caching filters. This feature can be useful in reverse proxy (surrogate) scenarios if many clients make the same query request.
- Always — all query responses from hosts matching the template are cached, if they are cacheable by HTTP 1.1 standards.
- Public — query responses from hosts matching the template are cached if they contain the Cache-control: public header or a forced revalidation header, and they are cacheable by HTTP 1.1 standards.
To configure query response caching in the Configuration and Administration forms, use the Cache Configuration –> Cache Behavior: Cache Query Response filtering by URL field. To specify two lists, create one list and then click Submit before creating the other list.
More requirements for query response caching
- CacheTimeMargin — This directive specifies a minimum expiration time; files with expiration times below this minimum are not cached. Because query responses sometimes have short expiration times, setting this directive to a lower setting allows more query responses to be cached. Refer to CacheTimeMargin — Specify the minimum lifetime for caching a file or use the Cache Expiration Settings form, which is described in Configuring cache freshness.
- CacheDefaultExpiry — This directive specifies the expiration time for files that do not have an explicit expiration date or a last-modified date from which to compute expiration time. Increasing this setting for HTTP requests from the default of 0 allows more query responses to be cached. However, changing the setting in this manner also increases the risk that stale content might be served from the cache. Refer to CacheDefaultExpiry — Specify the default expiration time for files or use the Cache Expiration Settings form, which is described in Configuring cache freshness.
- CacheLastModifiedFactor — This directive is used to calculate an expiration date for files that have a last-modified date but no explicit expiration date. Setting the factor for HTTP files to a higher value increases the amount of time an HTTP file resides in the cache without being revalidated. Changing the setting in this manner also increases the risk that stale content might be served from the cache. Refer to CacheLastModifiedFactor — Specify the value for determining expiration dates or use the Last Modified Factor form, which is described in Configuring cache freshness.
- Optionally, set the SignificantUrlTerminator directive and the AggressiveCaching directive. Refer to SignificantURLTerminator — Specify a terminating code for URL requests and AggressiveCaching — Specify caching for noncacheable files.
Caching locally served files
Because it is typically inefficient to cache files that are served from the proxy server, files originating in the server's local domain are not cached by default. To cache objects that originate in the server's local domain, check the Cache local domain files box on the Cache Configuration –> Cache Behavior Configuration and Administration form. Alternatively, set the CacheLocalDomain directive in the proxy configuration file to on.
Caching files by partial URL
Items can be cached based only on a specified (significant) part of the incoming URL, instead of the full URL. This is useful in transaction-model web serving or for dynamic caching because the same response is often returned for varying incoming requests when significant parts of the incoming requests' URLs are identical.
You cannot use the Configuration and Administration forms to specify caching that is based on partial URLs. Instead, use the SignificantUrlTerminator directive in the proxy configuration file to specify a terminating code for URL requests. This specification causes Caching Proxy to evaluate only characters before the terminating code when it processes the request and determines whether the requested file is cached. When more than one terminator code is defined, Caching Proxy compares incoming URLs against the terminator codes in the order in which they are defined in the ibmproxy.conf file.
Related configuration file directives
- NoCaching — Specify that files with URLs that match a template are not cached
- CacheOnly — Cache only the files with URLs that match a template
- CacheQueries — Specify cache responses to URLs containing a question mark (?)
- CacheLocalDomain — Specify whether to cache the local domain
- SignificantURLTerminator — Specify a terminating code for URL requests