Configuring Contextual Image Delivery caching
CID can cache both the images being transformed themselves, and the timestamps for those images. Configure caching to your liking by creating and editing a CID caching configuration file.
Procedure
- Access your installation media and navigate to configuration\samples\.
- From this location, copy ehcache_context_image_sample.xml to the WEB-INF/classes (Java) or bin\config\ (.NET) configuration folder of your Web application.
- Rename ehcache_context_image_sample.xml to ehcache_context_image.xml.
- Open ehcache_context_image.xml for editing.
- Configure the cache in one of the following ways:
- To configure caching settings for the image cache, edit the attributes of the
cacheelement with itsnameset tocom.sdl.context.image.api.ImageTransformer. - To configure caching settings for the timestamp cache, edit the attributes of the
cacheelement with itsnameset tocom.sdl.context.image.ImageUpdateTimeStamp.
- To configure caching settings for the image cache, edit the attributes of the
- Each of these elements has the following configurable attributes:
Attribute Description Default for image cache Default for timestamp cache eternalSet to trueto ignore all timeouts and never expire elements in this cache. If this attribute is set totrue,timeToLiveSecondsandtimeToIdleSecondsare ignored.falsefalsemaxBytesLocalDiskThe maximum amount of memory a cache can use in its local disk space. The value is a number followed by a letter indicating the unit of measurement. none none maxBytesLocalHeapThe maximum amount of memory a cache can use in its local heap memory. The value is a number followed by a letter indicating the unit of measurement. For example, "500k" denotes maxBytesLocalHeap"500 kilobytes", "200m" denotes "200 megabytes", "2g" denotes "2 gigabytes" and "20%" denotes "20 percent of available memory".10% 20M maxElementsInMemoryThe maximum number of items for this cache that can be in memory. Set to 0 to set no maximum. 1000 1000 maxEntriesLocalDiskThe maximum number of cache entries a cache can use in its local disk space. none none maxEntriesLocalHeapThe maximum number of cache entries a cache can use in its local heap memory. 1000 1000 overflowToDiskSet to trueif the disk cache should be used when local memory is used up.falsefalsestatisticsSet to falseif you do not want CID to gather caching statistics and make them available through the API.truetruetimeToIdleSecondsThe maximum number of seconds that an element can exist in the cache without being used. 1210 1220 timeToLiveSecondsThe maximum number of seconds that an element can exist in the cache, regardless of whether it is used or not. 2410 2420 - Save and close ehcache_context_image.xml.
- Only if you have pressing reasons to change the default caching behavior of CID, in the same location, open the configuration file cwd_engine_conf.xml.
- If you want to configure any of the following options, ensure the presence of a
<cache>section in this file and configure one or more of the following child elements:Child element Description Default if not specified configurationResourceNameThe name of the file that contains caching sessions. ehcache_context_image.xml recheckSourceSet to falseto stop the image transformer cache from checking source images for changes periodically.truecheckPeriodSet to an interval (in milliseconds) at which you want the cache to check for changes in resource images. 100000 (that is, every 100 seconds) enabledSet to falseto disable caching.true - By default, transformed images are written to memory only. If you want to enable the storage of transformed images in a temporary folder (for example, because you expect such images to be so large as to impact performance), ensure the presence of an
<image>section in this file and add the following within this section:<io> <useTempFileCache>true</useTempFileCache> </io> - Save and close cwd_engine_conf.xml.
- Restart the Web application to apply your changes.