Q: Is it possible to configure a NetScaler appliance not to cache a response even if a value is set in an HTTP header?
A: Yes. You can configure a NetScaler appliance not to cache a response even if a value is set in an HTTP header. However the procedure to configure the appliance for this requirement depends on the NetScaler software release installed on the appliance. Refer the appropriate section from the following sections to configure the appliance for this requirement.
Note: The policy engine in NetScaler software release 9.0 and later is different from the same in the NetScaler software release 8.x. As a result, the syntax has changed. However, the concept remains the same that the policy checks for the presence of a header in the HTTP response from the server or check for a specific string value in the response.
Configuring the NetScaler Appliance with a NetScaler Software Release 9.0 or later Installed on it
The following is the list of default cache policies that evaluate the response headers in the HTTP response from the server and have a NOPCACHE action:
add cache policy _uncacheableCacheControlRes -rule "((HTTP.RES.CACHE_CONTROL.IS_PRIVATE) || (HTTP.RES.CACHE_CONTROL.IS_NO_CACHE) || (HTTP.RES.CACHE_CONTROL.IS_NO_STORE) || (HTTP.RES.CACHE_CONTROL.IS_INVALID))" -action NOCACHEadd cache policy _uncacheableVaryRes -rule "((HTTP.RES.HEADER(\"Vary\").EXISTS) && ((HTTP.RES.HEADER(\"Vary\").INSTANCE(1).LENGTH > 0) || (!HTTP.RES.HEADER(\"Vary\").STRIP_END_WS.SET_TEXT_MODE(IGNORECASE).eq(\"Accept-Encoding\"))))" -action NOCACHE
add cache policy _uncacheablePragmaRes -rule "HTTP.RES.HEADER(\"Pragma\").EXISTS" -action NOCACHE
add cache policy _personalizedRes -rule "HTTP.RES.HEADER(\"Set-Cookie\").EXISTS || HTTP.RES.HEADER(\"Set-Cookie2\").EXISTS" -action NOCACHE
add cache policy do_not_cache -rule
The preceding policies are bound to the label _resBuiltinDefaults and are evaluated though a global binding with default priority of 185883, as shown in the following configuration entry:
bind cache global NOPOLICY -priority 185883 -gotoPriorityExpression NEXT -type RES_DEFAULT -invoke policylabel _resBuiltinDefaultsHowever, it is possible that you might configure an explicit cache policy with the CACHE action that overrides the default policies. As a result, the objects not intended to be cached are stored in the cache memory of the NetScaler appliance. To resolve this issue, you can configure a cache policy that verifies the presence of a specific header or the value of a specific header and then force the NOCACHE action. You can use any of the following sample actions configurations to resolve this issue:
- add cache policy do_not_cache -rule "http.RES.HEADER(\"<Header_Name>\").EXISTS" -action NOCACHE
bind cache global do_not_cache -priority 10 -gotoPriorityExpression END -type RES_OVERRIDE - add cache policy do_not_cache -rule "http.RES.HEADER(\"<Header_Name>\").CONTAINS(\"<Value>\")" -action NOCACHE
bind cache global do_not_cache -priority 10 -gotoPriorityExpression END -type RES_OVERRIDE
Note: Ensure that you specify a priority such that the policy precedes the policies with explicit CACHE action.
Configuring the NetScaler Appliance with a NetScaler Software Release 8.x Installed on it
The NetScaler software releases 8.x do not have default cache policies explicitly defined. However, these releases consist of two sets of default behavior, one of which you can override by using the –precedeDefRules YES option in the cache policy binding command.
If there is any cache policy with the CACHE action that overrides that default behavior, then you can resolve the issue running any of the following set of commands, as required:
- add cache policy do_not_cache -rule "REQ.HTTP.HEADER <Header_Name> EXISTS" -action NOCACHE
bind cache global do_not_cache -priority 10 -precedeDefRules YES - add cache policy do_not_cache -rule "REQ.HTTP.HEADER <Header_Name> CONTAINS \'<Value>\'" -action NOCACHE
bind cache global do_not_cache -priority 10 -precedeDefRules YES
Note: Ensure that you specify a priority such that the policy precedes the policies with explicit CACHE action.
More Information
Refer to the following Citrix documentation for more information about release specific Integrated Cache default behavior:
- CTX118570 – [Document Not Found]