cache_config

The `cache_config` directive allows users to define caching configurations within the NGINX Proxy-Wasm module.

Syntaxcache_config parameters;
Defaultnone
Context
Arguments1

Description

The cache_config directive is part of the NGINX Proxy-Wasm support module and is designed to enable and customize caching mechanisms for WebAssembly modules executed within the NGINX environment. When using this directive, developers can define how responses from proxied requests should be cached, including aspects such as the cache duration and cache key generation. This is particularly useful in scenarios where the output of a WebAssembly filter needs to be reused for efficiency, such as in high-load web applications or when repeatedly fetching the same data.

The directive accepts a single argument that specifies caching parameters. These parameters can control various elements of the caching behavior, such as the type of caching (in-memory, disk-based), time-to-live (TTL) for cached items, and handling of cache keys that influence how different responses are stored and retrieved. It integrates directly with the defined WebAssembly filter modules and enriches their capabilities, allowing for dynamic caching strategies to be implemented based on specific needs and contexts of the application.

When correctly configured, cache_config can significantly improve performance by reducing response times for repeated requests and minimizing upstream load. However, it’s also important for developers to consider cache invalidation strategies to ensure that users receive the most current data when necessary.

Config Example

wasm {
    module my_filter /path/to/filter.wasm;
    cache_config max_age=30s;
}

Ensure that the caching parameters are correctly specified; malformed syntax may lead to errors.

Take care to manage cache invalidation properly to avoid serving stale data to clients.

Not every WebAssembly module will be compatible with caching; check for requirements specific to your modules.

← Back to all directives