Would you like to learn how to disable the cache of files on the Nginx server? In this tutorial, we are going to configure the Nginx server to disable the cache of files.

• Ubuntu 18
• Ubuntu 19
• Ubuntu 20
• Nginx 1.18.0

This will disable the cache of files on the user browser.

Equipment list

The following section presents the list of equipment used to create this tutorial.

As an Amazon Associate, I earn from qualifying purchases.

Tutorial Nginx - Disable the Cache

Install the Nginx server.

Copy to Clipboard

Edit the Nginx configuration file for the default website.

Copy to Clipboard

Add the following headers to disable the cache of files.

Copy to Clipboard

Here is the file, before our configuration.

Copy to Clipboard

Here is the file, after our configuration.

Copy to Clipboard

Restart the Nginx service.

Copy to Clipboard

Optionally, disable the header named ETAG.

Copy to Clipboard

In our example, the remote user's browser will not cache files from this Nginx server.

From a remote computer, try to access a page from the Nginx server.

Copy to Clipboard

Here is the command output.

Copy to Clipboard

In our example, the Nginx server uses the connection header to tell the user's browser to not cache files.

Optionally, you may select only a list of file extensions to disable the cache.

Copy to Clipboard

Congratulations! You disabled the browser cache feature using the Nginx server headers.