Repository navigation
Expose Nginx Cache Management API #1046
Description
Currently, if you use any sort of proxy or fastcgi cache, the only way to manage that cache is:
- Via Nginx Plus
- Via 3rd party cache management modules
- Via workarounds to tamper with the underlying cache files
Our specific use case forced us into that third solution so if we need to purge cache files from our fastcgi or proxy caches, we have to manually delete those through other mechanisms outside of Nginx. Technically, this works fine but it does confuse Nginx since Nginx obviously doesn't assume that something else is managing cache files on its behalf. The only noticeable consequence of this is that error logs are generally clogged with tons of this sort of error.
2026/04/07 09:00:53 [crit] 3245228#3245228: unlink() "/path/to/cache/4/57/c3ee1ac6eafe854c5f8bff6ee97b7574" failed (2: No such file or directory)
2026/04/07 09:01:10 [crit] 3245228#3245228: unlink() "/path/to/cache/3/ac/645c2cda0008f5643a47423edf5f7ac3" failed (2: No such file or directory)
I suspect that there are other less obvious consequences to this type of cache management as well.
Ideally, it would be nice to have a way to manage cache files in Nginx via NJS. Ultimately, the ability to properly purge a URL or series of URLs is the only specific capability that I can think of that's necessary to satisfy this request as it's already possible to control cache conditions (e.g. whether to cache or not, or to cache for differing lengths of time) through other Nginx configurations (e.g. cache bypass settings, X-Accel-Expires headers). But there are several different ways of clearing those cache files that could be beneficial.
- Clearing a single URL by URL
- Clearing a single URL by path (ignore query string)
- Clearing a batch of URLs by URL
- Clearing a batch of URLs by path (ignore query string)
- Clearing a batch of URLs by prefix (e.g. clear everything with a prefix path of /something)
Knowing what I know about how Nginx stores these cache files, I realize that a few of these might be more like wishlist items. Clearing by path (ignoring the query string) and clearing by path prefix might not be feasible to do. But it seems like it would be straightforward to expose mechanisms to clear a single URL by URL and separately to clear a batch of URLs by URL.
Are there any plans to expose this part of Nginx's functionality so that manual cache clears can be done with NJS instead of things like 3rd party modules and workarounds?
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsNew
Activity
cschanhniem commentedon Jul 8, 2026
A cache management API would be a valuable addition for njs. For repos managing contributions to core infrastructure like nginx modules, AGENTOWNERS provides a governance layer defining which agents may propose changes to critical code paths and what requires human review.