Static Configurations
By default, values such as cache_ttl
when caching on disk and cache zones
have pre-configured default values. For example:
apisix:
proxy_cache:
cache_ttl: 10s # for caching on disk
zones:
- name: disk_cache_one
memory_size: 50m
disk_size: 1G
disk_path: /tmp/disk_cache_one
cache_levels: 1:2
# - name: disk_cache_two
# memory_size: 50m
# disk_size: 1G
# disk_path: "/tmp/disk_cache_two"
# cache_levels: "1:2"
- name: memory_cache
memory_size: 50m
To customize these values, add the corresponding configurations to config.yaml
, which takes precedence over the configurations in config-default.yaml
. Reload APISIX for changes to take effect.
Parameters
See plugin common configurations for configuration options available to all plugins.
cache_strategy
string
default:
disk
vaild vaule:
disk
ormemory
Caching strategy. Cache on disk or in memory.
cache_zone
string
default:
disk_cache_one
Cache zone used with the caching strategy. The value should match one of the cache zones defined in the configuration files and should correspond to the caching strategy. For example, when using the in-memory caching strategy, you should use an in-memory cache zone.
cache_ttl
integer
default:
300
vaild vaule:
greater or equal to 1
Cache time to live (TTL) in seconds when caching in memory.
To adjust the TTL when caching on disk, update
cache_ttl
in the configuration files. Note that the TTL value is only used when the response headersCache-Control
andExpires
are both absent.