Skip to content

Commit b63e1f9

Browse files
maximk-1denji
authored andcommitted
docs: document $cache_purge_queue_size and $cache_purge_queue_max_size variables
1 parent 46595ad commit b63e1f9

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -247,6 +248,39 @@ variant regardless.
247248

248249
---
249250

251+
## Variables
252+
253+
These read-only variables are always available when the module is loaded.
254+
They return `"-"` when `cache_purge_background_queue` is `off`.
255+
256+
### `$cache_purge_queue_size`
257+
258+
Current number of entries waiting in the background purge queue. Updated
259+
atomically — safe to read from any worker process. Useful for capacity
260+
monitoring and alerting.
261+
262+
### `$cache_purge_queue_max_size`
263+
264+
The configured maximum queue depth (`cache_purge_queue_size`). Constant for
265+
the lifetime of the nginx process. Useful alongside `$cache_purge_queue_size`
266+
to compute queue utilisation.
267+
268+
**Example — log queue depth on every request:**
269+
270+
```nginx
271+
log_format purge_mon '$remote_addr [$time_local] '
272+
'queue=$cache_purge_queue_size/$cache_purge_queue_max_size';
273+
access_log /var/log/nginx/purge.log purge_mon;
274+
```
275+
276+
**Example — expose as a response header:**
277+
278+
```nginx
279+
add_header X-Purge-Queue-Depth $cache_purge_queue_size;
280+
```
281+
282+
---
283+
250284
## Partial key purge
251285

252286
When the exact cache key is not known — for example because it includes cookie
@@ -421,6 +455,9 @@ keep `batch_size` low and `throttle_ms` high to avoid iowait spikes.
421455
Successful background purges return `202 Accepted`. The response body uses the
422456
format set by `cache_purge_response_type`.
423457

458+
Use `$cache_purge_queue_size` and `$cache_purge_queue_max_size` to track queue
459+
depth in logs or response headers — see [Variables](#variables).
460+
424461
Relevant log messages:
425462

426463
| Level | Condition |

0 commit comments

Comments
 (0)