I am using Nginx as a front server. Yesterday i edited some CSS files. But Nginx still serving old one. I am running Nginx in virtual-box. My friend suggested some solutions to clear Nginx cache.

If you are using virtualbox/vargant vm, this solution might solve your issue.

How to clear Nginx cache

Solution 1:-

sendfile might set to on in nginx.conf

Turned it off.

Solution 2:-

Remove all files from the cache directory.

find /path/to/your/cache -type f -delete

Solution 3:-

You can delete specific file cache. Search specific file:

grep -lr 'http://mydomain.pl/css/newedited.css' /var/nginx/cache/*

and deleted that one file.

Note : Append $ to the search term to get the exact hit.

Ex: grep -lr 'http://mydomain.pl/css/newedited.css$' /var/nginx/cache/*

Other solutions :-

  • Delete cache directory: var/cache/nginx
  • Turn on Gzip for these file types.
  • Clear the browser cache by header input.
    expires modified +90d;