Configuring Content Caching

Content Caching is performed by an HTTP virtual server. The virtual server stores common responses in a Web cache, and replies to common requests by serving the response directly from the Web cache.

Applying Content Caching to a Virtual Server

To configure Content Caching for an HTTP virtual server, click Services > Virtual Servers. Choose the virtual server from the list of available servers, and click the Edit button.

Locate "Content Caching" and click Edit. Enable or disable Content Caching for that virtual server using webcache!enabled.

To apply your changes, click Update.

ATTENTION
If Web Content Accelerator functionality is enabled for this virtual server, the Traffic Manager always stores optimized resources, such as combined images, in the cache regardless of the webcache!enabled setting. However, the Traffic Manager does not attempt to cache optimized HTML pages generated by the Web Content Accelerator unless this setting is enabled. If both the cache and Web Content Accelerator are enabled, the Traffic Manager also caches un-optimized resources that the Web Content Accelerator fetches.

Configuring Lifetimes

The Traffic Manager automatically caches the most frequently requested content, making optimum use of the Web cache.

For each virtual server that uses the Web cache, you can configure how long resources are cached before they become “stale” and are discarded. Use the following settings for this purpose:

Setting

Description

webcache!time

How long (in seconds) is a resource cached for?

webcache!errorpage_time

How long (in seconds) is an error page cached for?

webcache!refresh_time

How soon before a resource expires should the Traffic Manager begin refreshing it?

The Traffic Manager caches regular HTTP responses for the period of time set in webcache!time. The resource is loaded into the cache the first time that a remote client requests it; then subsequent requests for the same resource are served directly from the cache until the time expires.

If the resource is changed on the back-end server, it can take up to webcache!time seconds before the Traffic Manager notices and the cached copy is updated. For a description of how out-of-date content can be forced out of the cache, see Forcing Stale Content out of the Cache.

The Traffic Manager also caches error pages (404 Not Found, 410 Gone, 501 Not Implemented, and so on), but uses the webcache!errorpage_time setting to determine how long they are cached for before they are requested again from a back-end server. Typically, you do not want to cache error messages for very long; you should recheck the content more frequently so that the error message could be purged and replaced with the correct content.

The Traffic Manager never caches pages returned as a result of a server error, such as “503 Too Busy”.

Expiring Resources

The Traffic Manager does not automatically delete cached content upon expiry. If the cache becomes full and space is required for new content, the Traffic Manager frees up space by removing the least recently-used content. This is regardless of whether the cache contains more recently-used, but expired, content that could be deleted.

When a resource expires, requests for that resource are sent to the back-end servers until the complete resource is loaded into the cache again. If there are many concurrent requests for the same resource, or if the resource takes a long time to generate, this can cause a large spike of traffic to the back-end servers.

The webcache!refresh_time setting addresses this problem. This value controls how the Traffic Manager speculatively updates the cache when a resource is due to expire.

For example, suppose webcache!refresh_time is set to 10 seconds. In the final 10 seconds before a resource is due to expire, if the Traffic Manager receives a request for the resource, it forwards the request to the back-end server rather than using the cached response. If the back-end servers provide a valid response, this response is used to update the cache and the expiry counter is reset.

The Traffic Manager only sends a maximum of one request per second for each resource to the back-end servers during the webcache!refresh_time period. Other requests for the resource are met using the cached response. In this manner, the cache can be refreshed before it expires, avoiding a large flood of requests to the back-end servers.

Configuring Web Cache Memory Usage

Ivanti recommends you configure the memory usage of the Web cache carefully, to ensure that:

The cache is sufficiently large to contain all variants of the most frequently requested pages.

The cache is not too large that it causes the host machine to swap part of the running the Traffic Manager processes to disk.

All virtual servers share the same global cache memory, and the sizes are configured globally for your Traffic Manager.

To configure the Web cache memory sizes, click System > Global Settings > Cache Settings. The following settings apply:

Setting

Description

webcache!size

Upper limit for the amount of memory (in Mb) that the Web cache can consume. It can also be specified as a percentage of total system memory.

webcache!max_file_num

Limits the maximum number of entries that can be placed into the cache.

webcache!max_file_size

Determines the size of the largest file that will be inserted into the cache. This can be specified as a percentage of the total cache size, or as an absolute file size.

webcache!avg_path_length

This is the estimated average length of the path (including the query string) for resources being cached. An amount of memory equal to this figure multiplied by webcache!max_file_num will be allocated for storing the paths for cache entries.

webcache!max_path_length

This is an upper bound on how long a path can be when stored in the cache. Its purpose is to stop one very long URL using up excessive storage space.

webcache!verbose

Enable this setting to add a header named “X-Cache-Info” to HTTP responses to show whether the request/response is cacheable.

webcache!normalize_query

Enables normalization of the query string.

webcache!disk

Enables usage of a disk-backed cache. Refer to Configuring Disk-Based Caching.

webcache!disk_dir

If disk caching is enabled, this sets the directory where the disk cache file will be stored.

Monitoring Cache Activity

To monitor the activity of the Web cache, click Activity > Content Cache. This page displays the contents of your Web cache, and how many variants of each response are stored. The Content Cache page also indicates how much memory is used by your Web cache.

You can also reach this page by clicking View cache contents on the Virtual Server > Edit > Content Cache page.

The Content Cache activity page includes the percentage of allocated entries and memory that is currently in use, and a selector so that you can explore the content in the cache and manually expire cache items if desired.

If your cache is full, or almost full, either the Entries value will be close to the MaxEntries value, or the MemUsed value will be close to the MemMaximum value. In this case, when new entries are inserted into the cache, the least-used entries will be discarded before they expire. You can monitor the value of Oldest to determine the time since the least-used entry in the cache was last used.

To graph cache usage in real-time, click Activity > Current Activity to access the Traffic Manager’s activity monitoring page. In the “Settings” section, set Chart Data to “HTTP Content Cache”. This cache activity information is also available through SNMP.

Configuring Disk-Based Caching

Typically, the Traffic Manager’s cache resides in main memory and the size you select is determined by the quantity of RAM available after accounting for the operating system, application memory, network buffers, and so on.

As an alternative, the Traffic Manager may be configured to use a larger cache that is stored on a local disk. This results in an effective two-tier cache because the operating system will store the most active parts of the disk-based cache in memory, using the system’s kernel disk buffers.

Configuring the Cache

To use a disk-based cache, perform the following steps:

1.Click System > Global Settings > Cache Settings.

2.Configure the size of your cache, in MB or GB. This size might be several times larger than the amount of memory in the server.

3.Enable disk-backed caching with the webcache!disk setting.

4.Select a location for the disk cache. This location must be a local directory with sufficient free space, and you are strongly recommended to select a location on fast SSD (Solid State Drive) storage, rather than on a slower local HDD (Hard Disk Drive).

5.Click Update to save your settings.

6.To fully apply disk-based caching, restart your Traffic Manager from the System > Traffic Managers page.

The disk cache is not persistent, and is cleared and reset when the Traffic Manager software is restarted. You cannot share disk caches between multiple Traffic Manager systems.

SSD and HDD Disk Caches

The disk cache is stored in a single flat file created in the selected location. All reads and writes to the cache can potentially result in a disk access, although the host operating system will cache the most commonly accessed parts of the file and perform writes in the background.

You are very strongly recommended to use a local SSD drive for the cache files because reads, writes and seeks on these drives are very fast. Reads, writes and seeks on a HDD are much slower – a typical mechanical HDD is limited to several hundred disk operations per second, which then limits the number of requests per second the Traffic Manager can process via the cache.