ajp_store

The `ajp_store` directive enables the storage of responses from AJP proxied requests in the cache.

Syntaxajp_store on | off;
Defaultoff
Contexthttp, server, location
Arguments1

Description

The ajp_store directive is used in NGINX's AJP module to specify that the responses from the AJP backend should be cached. This directive, when set to on, instructs NGINX to cache the responses based on the configuration specified by other caching directives, which can enhance the performance of subsequent requests by serving cached content instead of retrieving it from the AJP backend each time. The caching mechanism adheres to the cache key configurations specified by related directives like ajp_cache_key, which defines how the uniqueness of each cached response is determined.

In use cases where the responses are expected to be static or infrequently changed, enabling ajp_store can greatly reduce latency and backend load, ultimately improving the user's experience on dynamic sites. The configuration of ajp_store should be aligned with an understanding of the underlying application behavior to ensure effective caching; for example, responses that vary based on user sessions may not be suitable for caching without proper key configurations.

The behavior of this directive is context-sensitive and can be used within the http, server, or location contexts, providing flexibility in how and where caching strategies are applied throughout the server configuration. It is crucial to ensure that the caching mechanism is applied correctly by examining other directives that handle caching granularity and expiration, as these will dictate the efficiency and relevance of cached responses.

Config Example

http {
    upstream tomcats {
        server 127.0.0.1:8009;
    }

    server {
        listen 80;

        location / {
            ajp_pass tomcats;
            ajp_store on;
        }
    }
}

Ensure that the caching does not interfere with dynamic responses that should remain unique per user.

Monitor cache sizes to avoid excessive memory usage, particularly with large or frequently changing datasets.

Make sure to configure cache keys adequately with ajp_cache_key to avoid unintended cache hits.

← Back to all directives