@@ -12,6 +12,7 @@ matches the purge request.
1212- [ Compatibility] ( #compatibility )
1313- [ Installation] ( #installation )
1414- [ Directives] ( #directives )
15+ - [ Variables] ( #variables )
1516- [ Partial key purge] ( #partial-key-purge )
1617- [ Sample configurations] ( #sample-configurations )
1718- [ Performance tuning] ( #performance-tuning )
@@ -253,6 +254,39 @@ variant regardless.
253254
254255---
255256
257+ ## Variables
258+
259+ These read-only variables are always available when the module is loaded.
260+ They return ` "-" ` when ` cache_purge_background_queue ` is ` off ` .
261+
262+ ### ` $cache_purge_queue_size `
263+
264+ Current number of entries waiting in the background purge queue. Updated
265+ atomically — safe to read from any worker process. Useful for capacity
266+ monitoring and alerting.
267+
268+ ### ` $cache_purge_queue_max_size `
269+
270+ The configured maximum queue depth (` cache_purge_queue_size ` ). Constant for
271+ the lifetime of the nginx process. Useful alongside ` $cache_purge_queue_size `
272+ to compute queue utilisation.
273+
274+ ** Example — log queue depth on every request:**
275+
276+ ``` nginx
277+ log_format purge_mon '$remote_addr [$time_local] '
278+ 'queue=$cache_purge_queue_size/$cache_purge_queue_max_size';
279+ access_log /var/log/nginx/purge.log purge_mon;
280+ ```
281+
282+ ** Example — expose as a response header:**
283+
284+ ``` nginx
285+ add_header X-Purge-Queue-Depth $cache_purge_queue_size;
286+ ```
287+
288+ ---
289+
256290## Partial key purge
257291
258292When the exact cache key is not known — for example because it includes cookie
@@ -428,6 +462,9 @@ keep `batch_size` low and `throttle_ms` high to avoid iowait spikes.
428462Successful background purges return ` 202 Accepted ` . The response body uses the
429463format set by ` cache_purge_response_type ` .
430464
465+ Use ` $cache_purge_queue_size ` and ` $cache_purge_queue_max_size ` to track queue
466+ depth in logs or response headers — see [ Variables] ( #variables ) .
467+
431468Relevant log messages:
432469
433470| Level | Condition |
0 commit comments