iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
To clear an NGINX cache on Linux, first identify the active cache directory from the loaded configuration, then delete everything inside that directory while leaving the directory itself in place. Clearing cache files alone does not require a restart or reload. You need nginx -t followed by a graceful reload only when you change cache configuration. URL-by-URL invalidation is a separate feature: NGINX Plus can handle controlled PURGE requests, while many open-source installations use filesystem cleanup.
What NGINX cache are you clearing?
NGINX caches responses as files on disk. The cache-path directive defines both the storage location and cache-zone settings, so the correct directory is whatever path appears in the configuration currently loaded by your server. Do not assume that /var/cache/nginx is active; packages and custom builds can use different paths.
Several NGINX modules have their own cache-path directive. Search for the directive that matches the cache you intend to invalidate:
| Directive | What it stores | What to record |
|---|---|---|
proxy_cache_path |
Responses cached by the HTTP proxy module | The filesystem path and the cache zone name |
fastcgi_cache_path |
Responses generated through FastCGI | The filesystem path and associated zone |
uwsgi_cache_path |
Responses generated through uWSGI | The filesystem path and associated zone |
scgi_cache_path |
Responses generated through SCGI | The filesystem path and associated zone |
Cache filenames are derived from the cache key and distributed into directory levels. That makes the layout efficient for NGINX, but it also means that guessing a filename from a URL is unreliable. Use the configured path and NGINX’s cache rules instead of trying to infer individual files.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application: attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Economical &Reusable: Built durable materials with a long-lasting battery,our CAGIWIRU air duster it's a sustainable alternative to disposable air cans.
Understand the cache zone before deleting anything
The name after a cache-path directive identifies a shared cache zone used by other directives such as proxy_cache. A server can define several zones, each with a different path or policy. Two virtual hosts might therefore use different directories even though both are served by the same NGINX process. Record both the path and zone name while inspecting the configuration, then trace the location handling the URL you are troubleshooting to the matching zone.
A cache path can also contain nested directory levels chosen by the cache configuration. Those levels are implementation details, not separate caches. Removing entries below the configured root clears the zone’s files; removing only one guessed subdirectory can leave valid entries behind.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Find the active cache directory
Inspect the configuration NGINX actually loaded
Run the configuration dump as root so included files and permission-protected files can be read:
sudo nginx -T 2>/dev/null | less
In less, search for /proxy_cache_path, /fastcgi_cache_path, /uwsgi_cache_path, and /scgi_cache_path. Record the path argument from the directive. Also note the zone name because a configuration can define more than one cache location.
The dump shows the complete configuration after includes are processed. A path in an included virtual-host file is just as important as one in the main nginx.conf; checking only the main file can make you miss the cache that serves the URL you are troubleshooting. If the dump shows several directives, make a short map of zone name, directory, and the server or location that references each zone before running a deletion command.
Locate the configuration file when -T is unavailable
Older or custom builds may not support nginx -T. Ask the binary where it was compiled to expect its main configuration:
nginx -V 2>&1 | tr ' ' 'n' | grep -- '--conf-path='
The result can point to a package-specific path such as /etc/nginx/nginx.conf or a source-built path such as /usr/local/nginx/conf/nginx.conf. Open that file and follow its include directives until you find the relevant cache-path directive. The compiled path varies by package and build, so treat the command’s output as authoritative for that server.
Do not edit a similarly named file in another installation tree and assume it controls the running service. The configuration loaded by the running binary, including its included files, is the one that determines where new cache files are written.
Confirm that the directory is the one you intend to purge
Before deleting anything, copy the path exactly, including escaped characters or spaces if the configuration uses them. Check that it exists and inspect its ownership and mode:
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
sudo ls -ld /path/to/cache
sudo stat -c '%U:%G %a %n' /path/to/cache
If several cache zones are defined, map each zone to its own directory. Purging one zone does not automatically clear another zone that happens to be on the same server.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Pause if the path is unexpectedly broad, such as a parent directory containing unrelated application data. Re-read the directive and its arguments rather than trying to compensate with a broader deletion. The safest purge command is the narrowest one that exactly names the configured cache root.
Full cache purge: remove contents, preserve the directory
Once the path is confirmed, remove the files and subdirectories below it while leaving the cache directory itself intact:
sudo find /path/to/cache -mindepth 1 -delete
The -mindepth 1 option prevents find from deleting the directory named in the command. It removes the cached files and the directory levels below it, including hidden entries. Replace /path/to/cache with the exact path recorded from the loaded configuration.
The command is intentionally aimed at the contents, not the root. NGINX expects the configured cache path to exist with suitable ownership and permissions. Deleting the root and recreating it with the wrong owner, group, or mode can prevent workers from writing new cache files. If you find that ownership changed, restore the values recorded before the purge and verify them again with stat or ls -ld.
Run the command once for the zone you selected. If you need to clear two zones, verify each path separately and repeat the operation for each one. Never replace the specific path with a common parent merely because the zones appear related; that can remove files belonging to another cache or application.
Purging only one of several cache zones
If the configuration contains multiple cache-path directives, run the command only against the directory belonging to the zone you want to invalidate. Do not substitute a common parent directory unless every cache below that parent is intentionally being cleared. A targeted filesystem purge is still an all-entries purge for that particular zone.
What happens after deletion
Deleting files does not disable caching. As requests arrive, NGINX can create new cache files under the same path according to the active policy. Seeing the directory repopulate is therefore expected. If a response must remain uncached, change the relevant cache directives or bypass rules separately; deleting existing files is an invalidation, not a permanent cache-off switch.
Because workers can continue serving traffic during a file-only purge, a request arriving immediately afterward may create a fresh entry before you finish checking the directory. Judge success by whether the old entry is gone and subsequent responses follow the current cache policy, not by whether the directory remains empty.
Recommended Free Tools
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
Do you need to restart or reload NGINX?
| Change you made | Required action | Availability impact |
|---|---|---|
| Deleted cached files only | No restart or reload is normally required | Workers can continue serving traffic and repopulate the cache |
| Changed a cache path, zone, policy, or included configuration | Run nginx -t, then perform a graceful reload |
Workers are replaced gracefully if validation succeeds |
| Stopped NGINX before deleting and recreating the directory | Start NGINX again after restoring ownership and mode | Requests are unavailable during the stop |
A cache-file purge changes data on disk, not the running configuration, so a reload is generally unnecessary. A reload becomes necessary only if you also edited configuration and want those edits applied. Restarting solely to make deleted files disappear adds an avoidable availability event.
Validate configuration changes before applying them
Run:
sudo nginx -t
The test checks syntax and attempts to open files referenced by the configuration. If it reports an error, fix that error before sending a reload signal. A failed test leaves the current configuration in service rather than replacing it with an invalid one.
Gracefully reload the validated configuration
After a successful test, use NGINX’s reload signal:
sudo nginx -s reload
On a systemd-managed installation, the service wrapper may be:
sudo systemctl reload nginx
Use the command supported by the installation. The underlying NGINX behavior is a reload signal: new workers use the validated configuration while old workers finish existing work and retire gracefully. A full restart is not required merely because cache files were removed.
Selective invalidation of one URL
Deleting a cache directory is a broad operation. If you need to invalidate one URL or a controlled group of keys, NGINX Plus documents the proxy_cache_purge directive and a persistent cache purger. The purge request must be deliberately enabled and access-controlled; it is not a method that should be exposed to the public Internet.
Selective invalidation depends on the cache key, not simply on a string that looks like a browser URL. Host, path, query-string handling, and other key rules in the active configuration determine which entry is matched. Send the purge request to the same host and path, with the request details expected by that key definition, and verify the result rather than assuming any 200-style response means the intended object was removed.
Configure a controlled PURGE method
A documented pattern maps the HTTP method to a purge flag and uses that flag in the location serving the proxy cache:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsmap $request_method $purge_method {
PURGE 1;
default 0;
}
location / {
proxy_pass http://backend;
proxy_cache mycache;
proxy_cache_purge $purge_method;
}
After placing the directives in the appropriate configuration context, validate and reload the configuration:
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
sudo nginx -t
sudo nginx -s reload
Then send a request for the exact URL whose cache key you intend to remove:
curl -X PURGE -D - 'https://example.com/path'
The response headers help you see how NGINX handled the request. The URL and request details must correspond to the cache key generated by your configuration; purging a different host, path, or key does not remove the entry you meant to target.
Protect the purge endpoint
Limit who can send PURGE requests with the access-control rules appropriate to your network and deployment. A public endpoint would let an unauthorised party repeatedly evict useful cache entries, increasing origin load. Keep the purge method restricted to trusted administrators, automation, or a private management network, and test the restriction from both an allowed and a disallowed client.
Free tools Windows power users keep installed
One-click scans. No signup required.
Apply the restriction in the location that actually handles the cached traffic, not in an unrelated virtual host. If you change the method mapping, access rule, or cache zone, run nginx -t before reloading. Keep the purge capability disabled in locations that do not need it.
Wildcard purge behavior
A wildcard key can match many cached entries. Matching files may remain on disk temporarily; NGINX can remove them later when they become inactive, when the cache purger processes them, or when a client accesses them. Therefore, a successful wildcard purge is a logical invalidation and does not necessarily mean that every matching file disappears immediately from the filesystem.
Do not combine a wildcard purge with an assumption that disk usage will fall instantly. If the operational goal is immediate removal of every file in a zone, a verified filesystem purge is the more direct operation. Use wildcard invalidation when logical URL-level control matters more than immediate directory cleanup.
Open-source NGINX considerations
proxy_cache_purge and the persistent purger are documented NGINX Plus features. Open-source deployments commonly perform a direct filesystem purge or install a separate purge module. Do not copy a Plus-only directive into an open-source build without confirming that the module exists; validate the configuration first with nginx -t.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Choosing the right clearing method
| Method | Scope | Configuration change? | Main risk | Best use |
|---|---|---|---|---|
| Delete contents of the configured directory | Every entry in one cache zone | No | Wrong path, ownership, or privileges | Emergency full invalidation or routine maintenance |
| Delete contents of one selected zone | Every entry in that zone only | No | Confusing zones or purging the wrong directory | Multi-zone configurations |
Controlled PURGE |
One URL/key or a wildcard set | Yes, when first configured | Unauthorised purge access or an incorrect key | Frequent, narrow invalidation on NGINX Plus |
| Stop, remove, recreate, and start | Every entry in the selected directory | Not necessarily | Service interruption and incorrect recreated permissions | Situations where live filesystem cleanup is unsuitable |
For a one-time emergency in an open-source installation, a direct purge is usually the shortest path: identify the zone, preserve the root, and delete its contents. For repeated deployments where only changed URLs should be evicted, a restricted Plus purge workflow avoids granting deployment scripts unrestricted filesystem access. In either case, scope and access control matter more than the command’s length.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting common failures
The cache appears unchanged
- Recheck the loaded configuration with
sudo nginx -T. The URL may use a different cache module or virtual host than the one you inspected. - Confirm that you deleted the directory named by the active cache-path directive, not a default directory left by an older package.
- Remember that traffic can repopulate an empty cache immediately. A non-empty directory after the purge does not prove that deletion failed.
- If the response is still stale, determine whether another caching layer is serving it. Clearing an NGINX zone cannot remove an entry held elsewhere.
- Check that the request is reaching the expected server and location. A different host or virtual host can legitimately use another cache zone.
find reports permission denied
Run the purge with sudo and verify that the path is correct. If access still fails, inspect the directory and its parent directories with ls -ld. Do not solve an uncertain permission error by deleting a broader parent path; first establish which account owns the configured cache directory and whether it is a mounted or protected filesystem.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
NGINX cannot write after the purge
Check that the cache directory still exists and that its owner, group, and mode match the values recorded before deletion. If the root directory was accidentally removed, recreate it with those original attributes before restarting or reloading NGINX. A configuration test can reveal referenced paths or permission problems:
sudo nginx -t
If the directory is present but newly created files still fail, compare the root directory’s attributes with the pre-purge stat output and confirm that you purged the intended zone rather than a parent path. Correct the filesystem attributes first, then test the configuration again.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The reload fails
Read the complete error from nginx -t. Common causes include a misspelled directive, an unavailable module, an invalid include, or a path that cannot be opened. Do not continue issuing reload commands until the test succeeds; the prior valid configuration remains active while the error is unresolved.
A PURGE request does nothing
- Confirm that the running build supports the purge directive and that the location uses the intended cache zone.
- Verify that the request reaches the expected host and path and uses the configured
PURGEmethod. - Check the access-control rule; an intentionally rejected request should not invalidate anything.
- For wildcard purges, inspect logical cache behavior rather than expecting every matching file to vanish instantly from disk.
- Review the cache-key rules so query strings or host names are not causing the request to target a different key than expected.
Safe operational checklist
- Back up or record the relevant cache-path directives and the directory’s owner, group, and mode.
- Dump the active configuration with
sudo nginx -T; if unavailable, locate the compiled configuration path withnginx -V. - Identify the exact cache zone and directory serving the content you want to invalidate.
- Check the directory with
ls -ldorstatbefore touching it. - For a full zone purge, run
sudo find /path/to/cache -mindepth 1 -delete. - Verify that the root directory still exists with the expected ownership and permissions.
- Do not reload for a file-only purge. If configuration changed, run
sudo nginx -tand reload only after it succeeds. - For repeated URL-level invalidation, use a restricted NGINX Plus purge configuration instead of granting scripts unrestricted filesystem access.
- Afterward, make a test request to the affected host and path and watch for expected cache repopulation rather than treating an empty directory as a permanent state.
Key points to remember
- The active cache path comes from a loaded
*_cache_pathdirective, not from a universal default. - NGINX cache data are files arranged according to the cache key and configured directory levels.
- A full purge removes the contents of a zone while preserving its root directory and permissions.
- Deleting cache files does not require a restart or reload; configuration edits do.
- Always test configuration with
nginx -tbefore reloading. - Selective
PURGErequests require deliberate configuration and strict access control, and wildcard matches may remain on disk temporarily.
Frequently Asked Questions
Where is the NGINX cache folder on Linux?
There is no universal location. Find the loaded proxy_cache_path, fastcgi_cache_path, uwsgi_cache_path, or scgi_cache_path directive with sudo nginx -T. The path argument in that directive is the active cache directory. If -T is unavailable, use nginx -V to locate the main configuration and follow its included files.
Can I delete /var/cache/nginx safely?
Only if the active configuration names that directory for the cache zone you intend to clear. Packages and source builds can use another path. Confirm with the loaded configuration first, record ownership and mode, then delete contents with find ... -mindepth 1 -delete while leaving the root directory in place.
Do I need to restart NGINX after clearing cache files?
No. Removing files changes cache data on disk, not the running configuration, so workers can continue serving and repopulate the zone. Restarting or reloading is needed when you change cache directives or other configuration. Validate those edits with nginx -t before a graceful reload.
How do I clear only one URL?
NGINX Plus supports proxy_cache_purge and controlled PURGE requests. Map the method to a purge flag, apply it to the location using the intended cache zone, restrict access, validate, reload, and send the request to the exact host and path used by the cache key. Open-source builds generally require filesystem cleanup or a separately installed purge module.
Why are cache files still present after a wildcard PURGE?
A wildcard purge can logically invalidate matching entries without immediately unlinking every file. Matching files may remain until they become inactive, a cache purger processes them, or a client accesses them. If immediate filesystem removal is required for an entire zone, use a verified contents purge instead.
What if NGINX cannot write new cache files after cleanup?
Check that the configured root directory still exists and compare its owner, group, and mode with the values recorded before deletion. Restore the original attributes if the directory was removed or recreated incorrectly, then run nginx -t to check referenced paths and configuration problems.
The Bottom Line
Locate the active *_cache_path directive, verify its directory and permissions, and remove only the contents with sudo find /path/to/cache -mindepth 1 -delete. No reload is needed for a file-only purge. If configuration changed, pass nginx -t first and then perform a graceful reload. Use tightly restricted PURGE requests for URL-level invalidation only when the running NGINX build supports them.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

