PHP-FPM – nginx – clear cache in different environments

Emma Sosa asked:

We have an environment with a web server running nginx, this has 4 virtual hosts (2 of them are the ones running in production, and the others 2 are for testing).
We run php-fpm and all that nginx cache thing. Now, i have two questions:

  • How do i manage to only have the cache running for production and no for testing virtual hosts?
  • And, every time a new thing is incorporated to production, devs have to wait to cache to clear itself, which last 1 hour (devs don’t have credentials to access the web server, they managed everything through a NFS). Is there a way to clear cache when they need to?

Thank you!

My answer:


You can have no cache in your testing virtual hosts by simply not specifying one. For example don’t put in any fastcgi_cache sort of directives.

And you can clear nginx’s cache by just deleting the files from disk. You should be able to find some way to work this into your deployment process.


View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.