Expose Nginx Cache Management API
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 30/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- javascript
- Domain
- api, backend, performance
Research direction
Start by reviewing the existing NJS APIs and how Nginx proxy and FastCGI cache files are managed. Narrow the proposed capabilities to a feasible cache-purge scope, then identify the relevant implementation entry points and validation needed for URL-based clearing. Done means an agreed, implementable API with clear behavior for individual and batch purges.
Written by the indexing model from the issue text.
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?
- Dominant language
- C
- Stars
- 1.6k
- Forks
- 245
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nginx/njs
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Modules: CR/LF in njs-produced nginx variablesMay be free again @xeioex claimed this 47 days ago, and no pull request is open. Opennjs
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Potential memory leak in njs_fs_fd_read error pathsPossibly taken @Shubham-Padkonde claimed this 42 days ago. Opennjs
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
msys2/MINGW-packages#33356 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
facebookincubator/muse-gadget-sdk#355 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
kmod-project/kmod#492 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PecanProject/sipnet#435 · 1 comment ·
Maintainers usually reply within 2 days
-
SDL_GPU Vulkan: wrong screen orientation on OpenHarmony (preTransform set without pre-rotation)Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
libsdl-org/SDL#16670 ·
Maintainers usually reply within 1 day