Search code examples
phpnginxfastcgi

How do I clear fastcgi_cache with PHP?


Is there a built-in way to clear the Nginx fastcgi_cache with PHP? I know I can write a PHP script that goes through and manually deletes all the cache files, but that seems too much like a hack.


Solution

  • If you have

    fastcgi_cache_path  /tmp/nginx keys_zone=myzone:8m
    

    just call

    rm -Rf /tmp/nginx/*
    

    It's really as simple as this: When you want to clean the cache, clean the cache :) (That in this case is just a folder)