Bottom Line: It is 100% safe to clear the Nginx cache (/var/cache/nginx). Clearing it will not delete your website files, databases, or Nginx server configuration.
What is the /var/cache/nginx Directory?
Located at /var/cache/nginx on Linux web servers, this directory is created when Nginx is configured as a reverse proxy or caching web server (proxy_cache or fastcgi_cache).
Nginx saves pre-rendered web pages, API responses, CSS, JS, and image files into this directory. When website visitors request a page, Nginx serves the cached copy from /var/cache/nginx instantly without querying backend PHP or Node.js servers.
Over time, or on high-traffic websites, the Nginx cache directory can expand to 10 GB to 100 GB+.
Can You Delete /var/cache/nginx?
✅ Yes, it is completely safe to clear.
- Zero website data loss: Your web application source code, databases (MySQL/PostgreSQL), and original media files are stored elsewhere.
- Purges stale content: Wiping the Nginx cache forces Nginx to fetch fresh web pages from your backend server.
How to Safely Clear Nginx Cache
Method 1: Delete Cache Files & Reload Nginx (Recommended)
- Open your server terminal.
- Delete all cached files inside the Nginx cache directory:
sudo rm -rf /var/cache/nginx/* - Reload Nginx to reset cache index handles:
sudo systemctl reload nginx
Related Guides
- Learn about cleaning [Redis dump.rdb snapshots].
- How to clean up Linux /var/log.
- Check if you can clean Browser Cache.
Discussion
Loading authentication...