The default values of the local response cache can be configured globally in a single place, as described in this section.
The configurable parameters are:
local.timeToLive
: sets the default time to expire a cache entry (expressed in s
for seconds, m
for minutes, and h
for hours). By default, it is 5 minuteslocal.size
: sets the default maximum size of the cache to evict entries for this route (in KB
, MB
, and GB
). By default, cache size is not limited. If neither of these parameters are specified, the default configuration as described in the global response cache guide will be used.apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: my-gateway
spec:
responseCache:
local:
size: 8MB
timeToLive: 10m
The local response cache implementation automatically calculates and sets the max-age
value in the HTTP Cache-Control
header. For a new cached response, the directive max-age
will be the timeToLive
configuration parameter. In consecutive calls this value will be recalculated and set to the number of seconds left before the cached entry is evicted.
In order to avoid repeating the LocalResponseCache
filter in every route, the flag local.global
can be set to true
in the SpringCloudGateway definition. Using the following definition, all the routes will cache with the described default configuration.
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGateway
metadata:
name: my-gateway
spec:
responseCache:
local:
global: true
size: 8MB
timeToLive: 10m