The compression scheme used for responses (the cache values) is specified through a class that implements the atg.search.routing.CacheValueCodec interface. This interface has encode() and decode() methods for compressing and decompressing the cache values.

The /atg/search/routing/CompressedCacheValueCodec component is of class atg.search.routing.CompressedCacheValueCodec, which implements the CacheValueCodec interface. This class produces the same compressed XML format that is returned for the response if the QueryRequest.respform property is set to comp. In addition, CompressedCacheValueCodec can optionally use GZIP encoding to further compress the response.

To use the compressed XML format for the cache values, set the cacheValueCodec property of the /atg/search/routing/RoutingSearchService component to the CompressedCacheValueCodec component:

cacheValueCodec=/atg/search/routing/CompressedCacheValueCodec

By default, the cacheValueCodec property is not set, and the uncompressed XML responses are used as the cache values.

To enable GZIP compression of the cache values, set cacheValueCodec to use the CompressedCacheValueCodec component as shown above, and set the gzip property of CompressedCacheValueCodec to true:

gzip=true

Note that if you change the type of compression used for responses, you should clear the cache. Otherwise, errors may occur because the current decoding algorithm will not be appropriate for the older cached responses.

Tradeoffs

Using the compressed XML format adds a small amount of processing time to the creation of cache values, but retrieving the response object in this format is actually faster than it is for uncompressed XML. There is no processing involved in the decode() method, as the compressed XML string is returned directly, and parsing the compressed XML value is two to five times faster than parsing regular response XML. However, the compressed XML format provides a savings of only about 35% in the space used to store the cache values.

Enabling GZIP compression significantly reduces memory and disk use for cache values (typically by a factor of 10) at the expense of CPU time. Encoding is considerably more processor-intensive than decoding, so a cache with many infrequently requested elements will involve a larger performance penalty than one with fewer, more frequently requested elements.