Avi Load Balancer can base the caching of responses based on URIs and MIME types. This section discusses both the options in detail.
MIME-type-based Caching
Previously the sole option, MIME-type-based caching is based on cache-control configuration parameters such as cacheable or non-cacheable MIME types within the application profile. This configuration determines whether Avi Load Balancer will cache a successful response from the server or not. If cacheable MIME types are configured (not the default), a 200 OK response from the server is cached only if its MIME type matches one of the references within the cacheable MIME types list. Otherwise, the response will not be cached.
If only a non-cacheable list of MIME types is configured, a 200 OK response with a matching MIME type will not be cached, and everything else will be cached. If the user configures both cacheable and non-cacheable lists of MIME types, then only responses matching the entries in the cacheable list are cached; any non-cacheable list is essentially disregarded.
Selective URI Caching
In contrast to MIME-type-based caching, selective URI caching is finer grained; it is based on a non-cacheable URI list. This list has match criteria and an option to configure a set of string groups, each of which stores one or more URIs as strings.
If a non-cacheable list of URIs is configured, a 200 OK response for a request URI that matches this list will not be cached. Following the outcome of processing the URI against this list, the cache/fetch decision also depends on request and response cache control headers, such as no-cache/no-store and other caching-related configurations specific to the application profile.
Figure 1 below shows the processing of a request URI against cacheable and non-cacheable MIME types and non-cacheable URI cache configuration.
Non-Cacheable URI PathMatch Configuration
In addition to enabling caching, the configuration accepts
A match criterion
An option to determine the case sensitivity
A list of URIs
| cache_config | | enabled | True | . . . | uri_non_cacheable | | match_criteria | DOES_NOT_EQUAL | | match_case | INSENSITIVE | | string_group_refs[1] | non-uri_sg
Full Set of uri_non_cacheable
Configuration Parameters
The match_criteria parameter can take on the following values:
BEGINS_WITH
DOES_NOT_BEGIN_WITH
CONTAINS
DOES_NOT_CONTAIN
ENDS_WITH
DOES_NOT_END_WITH
EQUALS
DOES_NOT_EQUAL
REGEX_MATCH
REGEX_DOES_NOT_MATCH
The match_case parameter can be either SENSITIVE or INSENSITIVE, with INSENSITIVE being default.
The string_group_refs parameter is a list of string-group references with URIs configured as strings in them. These can be configured by navigating in the Avi Load Balancer UI to .
If a
uri_non_cacheable
cache path match has no string_group_refs defined, then Avi Load Balancer does not do URI-based selective caching for the request.A
uri_non_cacheable
path match object can also have a string option (besides string groups). However, adding URIs as strings in a path match is not supported.
Ignore Request Cache Control
In an application profile’s cache configuration, if ignore_request_cache_control
is set to True
, then client cache-control headers (shown below) will be ignored, and Avi Load Balancer will fetch/store from/to the cache following the cache-control flow previously depicted. If this flag is set to False
, client cache-control flags in the request will be honored. By default, this flag is set to False
. The following cache expiration directive will be ignored when ignore_request_cache_control
is set to True
.
Cache Expiration Directive on Request
- Pragma: no-cache - Cache-control: no-cache | no-store max-age == 0
Query Cacheable
To match query parameters also along with the URI, the user must turn on the query_cacheable
option in the caching configuration to True
. This allows the caching logic to include query parameters also along with URI when matching against URI strings in string groups configured in uri_non_cacheable
configuration.
Sample CLI Configuration
Applicationprofile: http_profile: cache_config : enabled True xcache_header True age_header True date_header True min_object_size 10 max_object_size 4194304 default_expire 600 heuristic_expire False max_cache_size 0 query_cacheable True aggressive True uri_non_cacheable match_criteria EQUALS match_case INSENSITIVE string_group_refs[1] uri_strings ignore_request_cache_control True
Avi Load Balancer UI Configuration
Navigate to
.Create a new application profile or edit some pre-existing one.
Select the Caching tab in the New Application Profile window. Note that caching is off by default.
Select the Enable Caching option to reveal the Non-Cacheable URI option.
Select the Non-Cacheable URI option to enter the Critera and String group or custom string.
Click Save.