Product Documentation

Expiring or Flushing Cached Objects

Oct 28, 2013

If a response does not have an Expires header or a Cache-Control header with an expiration time (Max-Age or Smax-Age), you must expire objects in a content group by using one of the following methods:

  • Configure content group expiration settings to determine whether and how long to keep the object.
  • Configure an invalidation policy and action for the content group. For more information, see "Configuring Policies for Caching and Invalidation."
  • Expire the content group or objects within it manually.

After a cached response expires, the NetScaler appliance refreshes it the next time the client issues a request for the response. By default, when the cache is full, the NetScaler appliance replaces the least recently used response first.

The following list describes methods for expiring cached responses using settings for a content group. Typically, these methods are specified as a percent or in seconds:

  • Manual. Manually invalidate all responses in a content group or all responses in the cache.
  • Response-based. Specific expiration intervals for positive and negative responses. Response-based expiry is considered only if the Last-Modified header is missing in the response.
  • Heuristic expiry. For responses that have a Last-Modified header, heuristic expiry is a percentage of the time since the response was modified (calculated as current time minus the Last-Modified time, multiplied by the heuristic expiry value). For example, if a Last-Modified header indicates that a response was updated 2 hours ago, and the heuristic expiry setting is 10%, cached objects expire after 0.2 hours. This method assumes that frequently updated responses need to be expired more often.
  • Absolute or relative. Specify an exact (absolute) time when the response expires every day, in HH:MM format, local time or GMT. Local time may not work in all time zones.

    Relative expiration specifies a number of seconds or milliseconds from the time a cache miss causes a trip to the origin server to the expiration of the response. If you specify relative expiration in milliseconds, enter a multiple of 10. This form of expiration works for all positive responses. Last-Modified, Expires, and Cache-Control headers in the response are ignored.

    Absolute and relative expiration override any expiration information in the response itself.

  • On download. The option Expire After Complete Response Received expires a response as soon as it is downloaded. This is useful for frequently updated responses, for example, stock quotes. By default, this option is disabled.

    Enabling both Flash Cache and Expire After Complete Response Received accelerates the performance of dynamic applications. When you enable both options, the NetScaler appliance fetches only one response for a block of simultaneous requests.

  • Pinned. By default, when the cache is full the NetScaler appliance replaces the least recently used response first. The NetScaler appliance does not apply this behavior to content groups that are marked as pinned.

If you do not configure expiration settings for a content group, the following are additional options for expiring objects in the group:

  • Configure a policy with an INVAL action that applies to the content group.
  • Enter the names of content groups when configuring a policy that uses an INVAL action.

How Expiration Methods Are Applied

Expiration works differently for positive and negative responses. Positive and negative responses are described in the table, Expiration of Positive and Negative Responses mentioned below.

The following are rules of thumb for understanding the expiration method that is applied to a content group:

  • You can control whether the NetScaler appliance evaluates response headers when deciding whether to expire an object.
  • Absolute and relative expiration cause the NetScaler appliance to ignore the response headers (they override any expiration information in the response).
  • Heuristic expiration settings and “Weak Positive” and “Weak Negative” expiration (labeled as Default values in the configuration utility) cause the NetScaler appliance to examine the response headers. These settings work together as follows:
    • The value in an Expires or Cache-Control header overrides these content group settings.
    • For positive responses that lack an Expires or Cache-Control header but have a Last-Modified header, the NetScaler appliance compares heuristic expiration settings with the header value.
    • For positive responses that lack an Expires, Cache-Control, or Last-Modified header, NetScaler appliance uses the “weak positive” value.
    • For negative responses that lack an Expires or Cache-Control header, NetScaler appliance uses the “weak negative” value.

The following table describes how these methods are applied.

Table 1. Expiration of Positive and Negative Responses

Response Type

Expiration Header Type

Content Group Setting

Period the Object Remains in the Cache

Positive

any header

Expire Content After (relExpiry) with no other settings

Use the value of the Expire Content After setting.

Positive

any header

Expire Content At (absExpiry) with no other settings

Subtract current date from the value of the Expire Content At setting.

Positive

any header

Expire Content After (relExpiry) and Expire content at (absExpiry)

Use the smaller of the two values for the content group settings. See the previous rows in this table.

Positive

Last-Modified (with any other headers)

Heuristic (heurExpiry Param) with any other setting

Subtract the Last-Modified date from the current date, multiply the result by the value of the heuristic expiry setting, and then divide by 100.

Positive

Last-Modified (with any other headers)

Default (positive) (weakPosRel Expiry) and no other setting

Use the value of the Default (positive) expiry setting.

Positive

Expires or Cache-Control: Max-Age header is present

Last-Modified header is absent

Heuristic (heurExpiry Param), Default (positive) (weakPosRel Expiry), or both

Subtract the current date from the Expires or the Cache-Control:Max-Age date.

Positive

no caching headers

Default (positive) (weakPosRel Expiry) and any other expiration setting.

Use the value of the Default (positive) setting.

Positive

no caching headers

Heuristic (heurExpiry Param) is present

Default (positive) (weakPosRel Expiry) setting is absent

If the Last-Modified header is absent, the response is not cached or it is cached with an Already Expired status.

If the Last-Modified header is present, use the heuristic expiry value.

Negative

Expires or Cache-Control:Max-Age

Expire Content After (relExpiry), Expire Content At (absExpiry), or both settings

Subtract the current date from the value of the Expires header, or use the value of the Cache-Control:Max-Age header.

Negative

Expires or Cache-Control headers are absent

Expire Content After (relExpiry), Expire Content At (absExpiry), or both settings

Response is not cached, or is cached with an Already Expired status.

Negative

Expires or Cache-Control:Max-Age

Any setting

Subtract the current date from the Expires or Cache-Control:Max-Age date.

Negative

Expires and Cache-Control:Max-Age headers are absent

Default (negative) (weakNegRel Expiry)

Use the value of the Default (negative) setting.

Negative

Expires and Cache-Control:Max-Age headers are absent

Any setting other than Default (negative) (weakNegRel Expiry)

Object is not cached or is cached with an Already Expired status.