Kazyiski
Kazyiski

Reputation: 13

Symfony 2 deployment - cache handling

I'm following the instructions at this link to deploy my symfony2 application.

My question is strictly related to STEP D

D) Clear your Symfony Cache Make sure you clear (and warm-up) your Symfony cache:

$ php app/console cache:clear --env=prod --no-debug

When I run that command, all symfony cache is cleared, including doctrine cache. My application highly relies on doctrine cached data, so I was wondering if there is a way to avoid clearing the doctrine cache every-time I deploy. For example, I could be deploying only some small bug fixes in the application code, is it necessary to clear the cache every time? What would happen if I don't clear the cache after a minor bug fix?

Just to add some more context, my main issue is with doctrine cache. Because doctrine cache is stored inside the main symfony cache folder, and cache:clear dumps that folder, I lose my doctrine cache too. If I could separate doctrine cache from the main cache folder (setup a custom path) that would solve my issue.

Upvotes: 1

Views: 413

Answers (3)

Michal Takáč
Michal Takáč

Reputation: 1055

When you do some design fix for example you don't need to clear all cache. You can go to the cache directory and manualy delete only those cache files that you want to remove and leave Doctrine cache untouched.

Upvotes: 0

eRIZ
eRIZ

Reputation: 1507

It's highly recommended to clear the cache every time. For example, you create a new class you depend on. If you don't clear the cache, autoloader won't load your new class. Of course, only in production mode because dev has a bit different autoloading logic.

However, there's no single answer on your question - there are some issues on application acting connected with cache "freshness". You have definitely to clear it on database/entity structure change, routes and classes structure, annotations, configuration. In prod env, they are preprocessed to improve performance - after caching, the original values (config/routes) are unused till the next cache clearing.

Upvotes: 0

Paul Andrieux
Paul Andrieux

Reputation: 1847

Maybe you could use a automatic deployment system as Capifony that is really simple to setup and creates "releases".

That means that when you deploy, the application is stored into a new standalone folder, the vendors are installed, the assets are dumped and the cache is cleared. This folder is used for production only when these process are done, so you doesn't have any down-time

Upvotes: 0

Related Questions