Safe to Delete

Nginx Proxy & FastCGI Cache (/var/cache/nginx)

Quick Answer: /var/cache/nginx stores cached HTML pages, images, and proxy responses. Deleting Nginx cache is safe and purges stale website pages.

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

  1. Open your server terminal.
  2. Delete all cached files inside the Nginx cache directory:
    sudo rm -rf /var/cache/nginx/*
  3. Reload Nginx to reset cache index handles:
    sudo systemctl reload nginx

Discussion

Loading authentication...

Related in linux

Linux Audit Framework Log Directory (/var/log/audit)

The Linux auditd service records security events, file access traces, and user commands in /var/log/audit. Learn how to clean auditd log files safely.

Safe to Delete

Fail2ban Ban History Database (/var/lib/fail2ban/fail2ban.sqlite3)

Fail2ban intrusion prevention daemon logs banned IP addresses and SSH brute-force attempts in fail2ban.sqlite3. Clearing Fail2ban database is safe.

Safe to Delete

GNOME Desktop File Indexer Database (~/.local/share/tracker/data)

GNOME Tracker caches desktop search index databases. Resetting the tracker database is safe.

Safe to Delete
Back to all files