Configure selectors and basic content groups
hit parameters and invalidation parameters. However, Citrix recommends that you configure selectors.
Advantages of selectors
Use parameters Instead of selectors
hit parameters and invalidation parameters. For example, suppose that you configure three hit parameters in a content group for bug reports: BugID, Issuer, and Assignee. If a request contains BugID=456, with Issuer=RohitV and Assignee=Robert, the NetScaler appliance can serve responses that match these parameter-value pairs.
hit parameter or an invalidation parameter.
-
URL query
-
POST body
-
Cookie header
Configure a selector
add cache selector \<selectorName\> ( \<rule\> ... )
>add cache selector product_selector "http.req.url.query.value(\"ProductId\")" "http.req.url.query.value(\"BatchNum\")" "http.req.url.query.value(\"depotLocation\")"
> add cache selector batch_selector "http.req.url.query.value(\"ProductId\")" "http.req.url.query.value(\"BatchId\")" "http.req.url.query.value(\"depotLocation\")"
> add cache selector product_id_selector "http.req.url.query.value(\"ProductId\")"
> add cache selector batchnum_selector "http.req.url.query.value(\"BatchNum\")" "http.req.url.query.value(\"depotLocation\")"
> add cache selector batchid_selector "http.req.url.query.value(\"depotLocation\")" "http.req.url.query.value(\"BatchId\")"
Content groups
-
Static content groups. Finds an exact match between the URL stem and host name on the request and the URL stem and host name of the response.
-
Dynamic content groups. Looks for objects that contain particular parameter-value pairs, arbitrary strings, or string patterns. Dynamic content groups are useful when caching data that is updated frequently (for example, a bug report or a stock quote).
-
A user enters search criteria for an item, such as a bug report, and clicks the Find button in an HTML form.
-
The browser issues one or more HTTP GET requests. These requests contain parameters (for example, the bug owner, bug ID, and so on).
-
When the NetScaler appliance receives the requests, it searches for a matching policy, and if it finds a caching policy that matches these requests, it directs the requests to a content group.
-
The content group looks for appropriate objects in the content group, based on criteria that you configure in a selector.
NameField=username and BugID=ID.
-
If it finds matching objects, the NetScaler appliance can serve them to the user's browser, where they are assembled into a complete response (for example, a bug report).
-
A user modifies data (for example, the user modifies the bug report and clicks the Submit button).
-
The browser sends this data in the form of one or more HTTP requests. For example, it can send a bug report in the form of several HTTP POST requests that contain information about the bug owner and bug ID.
-
The NetScaler appliance matches the requests against invalidation policies. Typically, these policies are configured to detect the HTTP POST method.
-
If the request matches an invalidation policy, the NetScaler appliance searches the content group that is associated with this policy, and expires responses that match the configured criteria for invalidation.
NameField=username and BugID=ID.
-
The next time the NetScaler appliance receives a GET request for these responses, it fetches refreshed versions from the origin server, caches the refreshed responses, and serves these responses to the user's browser, where they are assembled into a complete bug report.
Set up a basic content group
add cache contentgroup <name> (-hitSelector <hitSelectorName> -invalSelector <invalidationSelectorName> | -hitParams <hitParamName> -invalParams<invalidationParamName>) -type <type> [-relExpiry <sec> | -relExpiryMilliSec <msec>] [-heurExpiryParam <positiveInteger>]
add cache contentgroup Products_Details –hitSelector product_selector –invalSelector id_selector
add cache contentgroup bugrep -hitParams IssuePage RecordID Template TableId -invalParams RecordID -relExpiry 864000
Expire or flush cached objects
-
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.
-
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, the heuristic expiry specifies the mount of time taken from when the response was modified (calculated as the 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 must 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.
-
On download. The option Expire After Complete Response Received expires a response when it is downloaded. This is useful for frequently updated responses, for example, stock quotes. By default, this option is disabled.
-
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.
-
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
-
You can control whether the NetScaler appliance evaluates response headers when deciding whether to expire an object.
-
Absolute and relative expiration causes 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, the NetScaler appliance uses the “weak positive” value.
-
For negative responses that lack an Expires or Cache-Control header, the NetScaler appliance uses the “weak negative” value.
-
| 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. |
Expire a content group by manual method
expire cache contentGroup <name>
Configure periodic expiration of a content group
set cache contentgroup \<name> (-relExpiry|-relExpiryMilliSec|-absExpiry|-absExpiryGMT| -heurExpiryParam|-weakPosRelExpiry|-weakNegRelExpiry| -expireAtLastBye) \<expirationValue>
Expire individual responses
ETag or Last-Modified headers, cannot be revalidated. As a result, flushing these responses has the same effect as expiring them.
expire cache object -url <URL> -host <hostName> [-port <port>] [-groupName<contentGroupName>] [-httpMethod GET|POST]
expire cache object -locator <positiveInteger>
Flushing responses in a content group
flush cache contentGroup <name> [-query <queryString> | [-selectorValue <selectorExpressionIDList> -host <hostName>]]
-
Navigate to Optimization > Integrated Caching > Content Groups.
-
In the details pane, flush the responses as follows:
-
To flush all responses in all content groups, click Invalidate All, and flush all the responses.
-
To flush responses in a particular content group, select the content group, click Invalidate, and flush all the responses.
-
flush cache object -locator <positiveInteger> | -url <URL> -host <hostName> [-port <port>] [-groupName <contentGroupName>] [-httpMethod GET|POST]
Deleting a content group
rm cache contentgroup <name>