Reputation:
Is there an easy way for fast removing http cache in symfony2? We've over 30.000 files in cache directory and removing them tooks very long. Is there an better way for doing this? Btw...linking the cache to /dev/null when removing...
Upvotes: 1
Views: 1282
Reputation: 3710
If you look in Symfony's cache directory /var/cache/
you'll find an http_cache
directory.
So you could use PHP's exec()
to remove the directory.
$root = $this->get('kernel')->getRootDir();
$path = $root . '/../var/cache/prod/http_cache';
exec('rm -rf ' . $path);
Upvotes: 1
Reputation: 4981
The easiest way to clear cash would be to use console command:
app/console cache:clear
If this is production – you need to add environment (using paramentr --env=prod. )
As default all console commands run in the dev environment.
So, for example, this command looks like app/console cache:clear -e=prod.
Upvotes: 1
Reputation: 716
Would always recommend using the Symfony console:
php app/console cache:clear --env=prod
This should be fastest, as it moves/renames your current cache folder and creates a new one before deleting your old cache, so there should zero downtime.
Upvotes: 0