The question:
Are sf2 caches directory-independent? Ie: Can I do cache:clear in a certain dir and then move the project dir to another machine/directory without breaking the caches?
The scenario:
- We have an application based on Symfony2.
- The production machine has 500MB.
- We currently deploy by uploading the soft and then clearing the caches.
- In the production machine,
app/console cache:clearlasts about 5 mins to be generated. - In a devel-machine with 2GB it lasts just a few seconds.
We have a requirement to minimize time-to-production. 5 mins waiting the caches is too much.
We thought about running the cache:clear in a local machine and then upload the product to production with the caches already generated. The local paths of the project (/home/ubuntu/devel/…) are different to the production paths (/var/www) and cannot be tuned to be the same.
Symfony2 cache uses absolute paths in various places, so you can’t copy the cache from one machine to the other, if the paths differ.
What you are really looking for is deployment via capifony. Upon deployment it creates a new folder on your live machine, prepares the new version of your project in that folder (includes publishing assets, clearing the cache and so on) and then simply switches the old folder with the new folder.
As a certain number of old versions is kept on the live server, you can even do a rollback if you have to.
And you can build a nifty one click deployment with capifony and Jenkins CI 😉