Selective Caching

With release 18.1.2, Avi Vantage can base the caching of responses based on URIs as well as MIME types.

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 config determines whether a successful response from the server will be cached by Avi Vantage or not. If cacheable MIME types is configured (it is 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 be not be cached. If only a non-cacheable list of MIME types is configured, a 200 OK response with 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 (new for 18.1.2) 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 configuration specific in the application profile.

Figure 1 below shows processing of a request URI against cacheable and non-cacheable MIME type and non-cacheable URI cache configuration.

Flow diagram
Figure 1. Flow diagram


Non-Cacheable URI PathMatch Configuration

In addition to enabling caching, the configuration accepts

  • a match criterion,
  • an option to determine case sensitivity, and
  • 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

  1. 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
  1. The match_case parameter can be either SENSITIVE or INSENSITIVE, with INSENSITIVE being default.

  2. 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 UI to Templates > Groups > String Groups.

Note:

  1. If a uri_non_cacheable cache path match has no string_group_refs defined, then Avi Vantage does not do URI-based selective caching for the request.

  2. 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 Vantage 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 params 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 configred 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 UI Configuration

Navigate to Templates > Profiles. Create a new application profile or edit some pre-existing one. Select the Caching tab. Note that caching is off by default, as shown in Figure 2.

Caching tab of the application profile editor
Figure 2. Caching tab of the application profile editor


Click the checkbox to reveal more caching options. Once caching has been clicked ON, the selective caching checkbox (unchecked by default) likewise needs to be clicked to reveal and/or set options:

UI screenshot
Figure 3. Application profile editor showing all caching options