I use nginx to as the front server, I have modified the CSS files, but nginx is still serving the old ones.
I have tried to restart nginx, to no success and I have Googled, but not found a valid way to clear it.
Some articles say we can just delete the cache directory: var/cache/nginx
, but there is no such directory on my server.
What should I do now?
For those who other solutions are not working, check if you're using a DNS service like CloudFlare. In that case activate the "Development Mode" or use the "Purge Cache" tool.
You can delete cache directory of nginx or You can search specific file:
And delete only one file to nginx refresh them.
I had the exact same problem - I was running my nginx in Virtualbox. I did not have caching turned on. But looks like
sendfile
was set toon
innginx.conf
and that was causing the problem. @kolbyjack mentioned it above in the comments.When I turned off
sendfile
- it worked fine.This is because:
You can also bypass/re-cache on a file by file basis using
and as a bonus you can return this header to see if you got it from the cache (will return 'HIT') or from the content server (will return 'BYPASS').
to expire/refresh the cached file, use curl or any rest client to make a request to the cached page.
this will return a fresh copy of the item and it will also replace what's in cache.
Be careful to properly specify the correct path.
We have a very large nginx cache (gigabytes) that we occasionally need to wipe. I've worked out a script that instantly clears the cache (as far as Nginx is concerned) and then removes the cache directory without starving the main application for disk I/O.
In summary:
Here's the script, tailored to Ubuntu 16.04 LTS, with the cache located at
/mnt/nginx-cache
:And in case it's helpful, here's the Nginx config we use: