Skip to content

Tags: nginx-modules/ngx_cache_purge

Tags

3.0.2

Toggle 3.0.2's commit message

Verified

This commit was signed with the committer’s verified signature.
denji Denis Denisov
ngx_cache_purge: correctness, safety, and build fixes

Fix use-after-free race in process_queue().  The original code unlocked
the queue mutex, walked the cache directory, then re-acquired the lock to
free the item.  Restructure to dequeue under the lock, unlock, then walk
and free outside it.

Fix vary_aware variant deletion leaving stale shared-memory state.  The
directory walk called ngx_delete_file() on variant files without updating
their rbtree nodes, leaving fcn->exists set and cache->sh->size inflated
until restart.  Add ngx_cache_purge_invalidate_node() to clear each
variant's rbtree metadata under shpool->mutex before the file is removed.

Fix live reload not applying changed queue configuration.  init_shm_zone()
reused the existing queue on reload but never updated throttle_ms or
queue_size; changes required a full restart to take effect.

Fix integer overflow in shm_size arithmetic on 32-bit builds.  Add
NGX_CACHE_PURGE_QUEUE_SIZE_MAX and reject queue_size=0 in init_main_conf.

Fix queue->size declared as ngx_atomic_t despite being accessed only under
queue->mutex.  Change to ngx_uint_t.  Fix data race reading queue->size
after unlock in the enqueue debug log.

Fix mid-scope variable declarations in fastcgi, proxy, scgi, and uwsgi
handlers to comply with gnu89.

Replace magic constant 6 (KEY: header offset) with named constant
NGX_CACHE_PURGE_KEY_HDR_OFFSET.  Add NULL guard for cplcf->conf in the
access handler.  Mark response size globals const.  Remove redundant
variables in send_response().

Fix config shebang from bash to sh; remove write to $NGX_AUTOCONF_ERR
which is reserved for the nginx build system.

Add basic.t TEST 15 covering the vary_aware purge path.  Add
purge_servroot() to run_tests.sh to clean up between prove invocations.

3.0.1

Toggle 3.0.1's commit message

Verified

This commit was signed with the committer’s verified signature.
denji Denis Denisov
fix response_type context and duplicate detection

The cache_purge_response_type directive had a flawed duplicate detection
guard that only checked for NGX_HTTP_LOC_CONF. This silently allowed
duplicate directives in http and server contexts to overwrite previous
values without throwing a configuration error. Additionally, a defunct
guard attempting to check for NGX_HTTP_MODULE was comparing context
flags against module-type magic bits, rendering it dead code.

Remove the invalid NGX_HTTP_MODULE check and make duplicate detection
unconditional. The directive is intentionally valid in http, server,
and location contexts, and merge_loc_conf propagates the value downward
appropriately. The README context documentation is updated to reflect
this correctly.

Furthermore, rename the internal configuration variable from resptype
to response_type for clarity. Fix a typo in the response type macro
definitions (NGX_REPONSE_TYPE_* to NGX_CACHE_PURGE_RESPONSE_TYPE_*)
and properly namespace them.

Clarify the documentation and internal comments for the
cache_purge_throttle_ms directive. Bare integers are evaluated as
milliseconds natively to match the directive's name, which differs
from the standard nginx time parser, logging a startup warning.

Add comprehensive test coverage in config.t to ensure proper context
inheritance, duplicate config rejection, and explicit time suffix parsing.

3.0.0

Toggle 3.0.0's commit message

Verified

This commit was signed with the committer’s verified signature.
denji Denis Denisov
log: add missing coverage for all silent error and debug paths

2.5.6

Toggle 2.5.6's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix purge segfault due to struct change in 1.29.4 (#52)

Fixes #51

2.5.5

Toggle 2.5.5's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix segfault when using same-location syntax with variable cache zones (

#50)

2.5.4

Toggle 2.5.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Fix memory leak when using partial (wildcard) keys. (#46)

Resolved #45

2.5.3

Toggle 2.5.3's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Fix race-condition with two parallel PURGE (#42)

2.5.2

Toggle 2.5.2's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Update structs for nginx 1.19.4+ and 1.21.0+ (#41)

2.5.1

Toggle 2.5.1's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
empty key check

it coredumps when cache key is empty

2.4.3

Toggle 2.4.3's commit message

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
empty key check

it coredumps when cache key is empty