1

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...

1

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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);

Comments

0

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.

1 Comment

Well, the problem is, that removing 30.000 files from fs tooks very long and takes high system ressources...Im looking for a way for fast removing the files...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.