You need to clear the cache so Symfony can rebuild its compiled configuration, routes, and templates after your code or settings have changed.
1. Where Symfony Stores Cache
Symfony stores its cache under:
var/cache/{environment}/
For example:
- Development: var/cache/dev/
- Production: var/cache/prod/
2. When to Clear Cache
| Environment | Auto Clears | When to Clear Manually |
|---|---|---|
| dev | Yes | Usually unnecessary, unless configuration or .env changes |
| prod | No | Always after uploading or modifying PHP, Twig, or config files |
Why Production Cache Does Not Auto-Clear
Symfony’s production mode (APP_ENV=prod) is optimized for speed and stability.
It compiles routes, Twig templates, and the service container into cached PHP files.
These precompiled files allow each request to run faster and use less memory.
If Symfony automatically rebuilt cache on every change, it would:
- Slow down every request,
- Constantly recompile the container,
- Defeat the purpose of production mode.
In development mode (APP_ENV=dev), Symfony detects file changes automatically.
In production mode, that check is disabled for performance reasons,
so you must clear cache manually after any code or configuration changes.
3. Clearing Cache with Command
Production
php bin/console cache:clear --env=prod --no-warmup
php bin/console cache:warmup --env=prod
Development
php bin/console cache:clear --env=dev
4. Clearing Cache via FTP (No SSH Access)
If you cannot run console commands:
-
Connect to your site using FTP or file manager.
-
Navigate to:
var/cache/prod/ -
Delete everything inside that folder.
-
Symfony will rebuild the cache automatically on the next page load.
Do not delete the
"var/cache"folder itself — only the files inside"var/cache/prod/".
In other words, delete"var/cache/prod/*"but not"var/cache/**".