I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

How to clear the Nginx Cache

Hello friends. In this post, you will learn how to clear the Nginx cache. This process is convenient to do when making deep changes to the website that we manage.

Nginx, like other web servers, has a cache where they store sensitive data to improve site performance and shorten response times.

The problem comes when deep changes are made to the site and by default, Nginx will query that cache and if it has not been updated, then it may not reflect some changes.

But what changes are we talking about? Mainly those internal configurations like plugins or memory management. But that, in a large site, could bring issues for the end user.

The process is easy, but it’s good to know and have it around for any situation.

Clear the Nginx cache

In this post, I will show you two different but quite effective methods. You can choose one or the other.

Method 1: Clearing the cache using the Nginx utility

The first method is said to be the most recommended because it is Nginx itself that efficiently takes care of the cache deletion.

To achieve this, open a terminal and run with root permissions

nginx -s reload

This command tells Nginx to restart all the configurations and to delete the cache.

This will make the deep changes made to the site take effect immediately, without waiting for the cache to expire.

Method 2: Clear the nginx cache manually

Another method is to delete these files manually in the Nginx cache directory.

Usually, the directory is /var/cache/nginx/ so each of these files refers to the cache.

rm /var/cache/nginx/*

This method is effective, but few recommend it as it may affect other unwanted configurations.

In any case, after clearing the cache, it is advisable to restart Nginx.

systemctl restart nginx

This will ensure that all changes are made.


In this post, you learned how to clear the Nginx cache. Two methods to achieve the same thing, but you can always add them to configuration scripts to automate the process.

Posts about nginx


Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook