Skip to main content

Static Configurations

By default, values such as cache_ttl when caching on disk and cache zones are pre-configured in the default configuration file. For example:

apisix:
proxy_cache:
cache_ttl: 10s # default cache TTL used when caching on disk, only if none of the `Expires`
# and `Cache-Control` response headers is present, or if APISIX returns
# `502 Bad Gateway` or `504 Gateway Timeout` due to unavailable upstreams
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 or memory


    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_key

    array[string]


    default: ["$host", "$request_uri"]


    Key to use for caching.

    Support built-in variables and constant strings in values. Variables should be prefixed with a $ sign.

  • cache_bypass

    array[string]


    One or more parameters to parse value from, such that if any of the values is not empty and is not equal to 0, response will not be retrieved from cache.

    Support built-in variables and constant strings in values. Variables should be prefixed with a $ sign.

  • cache_method

    array[string]


    default: ["GET", "HEAD"]


    vaild vaule:

    Any combination of methods from "GET", "POST", and "HEAD"


    Request methods of which the response should be cached.

  • cache_http_status

    array[integer]


    default: [200, 301, 404]


    vaild vaule:

    Any combination of integer values from 200 to 599 inclusive


    Response HTTP status codes of which the response should be cached.

  • hide_cache_headers

    boolean


    default: false


    If true, hide Expires and Cache-Control response headers.

  • cache_control

    boolean


    default: false


    If true, comply with Cache-Control behavior in the HTTP specification. Only valid for in-memory strategy.

  • no_cache

    array[string]


    One or more parameters to parse value from, such that if any of the values is not empty and is not equal to 0, response will not be cached.

    Support built-in variables and constant strings in values. Variables should be prefixed with a $ sign.

  • 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. The TTL value is evaluated in conjunction with the values in the response headers Cache-Control and Expires received from the upstream service.


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IRed Herring

Copyright © APISEVEN Ltd. 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation