Symfony / Empty and regenerate the cache of OPcache
Permanently deleted user
Hi,
I’m working on a Symfony app and was reviewing the performance recommendation here: https://symfony.com/doc/current/performance.html#don-t-check-php-files-timestamps
Do I have to do something special to ensure one of the 3 items is done? Or does the first one (Restart the web server) is done anyhow?
Thanks for your help ![]()
0
Comments
Most of that is covered in our PHP Tuning guide, here:
https://docs.platform.sh/languages/php/tuning.html#configure-opcache
The opcache file check is on by default to support applications that generate code at runtime. You can turn it off yourself via
.platform.app.yamllike so:The PHP-FPM server is restarted when you update code anyway. The default composer command we use already optimizes the autoloader.
Cheers.
Thanks! Really helpful
I setup things like that, but I find myself having to redeploy, because deployments seems to be using the previous file versions
Any idea what could be causing this?
After investigating a bit, I found that sometimes Symfony templates are not updated correctly and still using their previous (probably cached) version.
Can you help me with that?
Thanks!
Could it be a case of not triggering a new build, just a deploy, and so you don’t get updated code? I assume by Symfony templates you mean compiled Twig templates.
(Sorry for the delay; Discourse’s notifications are not great.)
Yes: compiled Twig templates.
Maybe. But what does pushing code to Platform.sh do? Isn’t it supposed to trigger a new build?
Yes, a code push that changes files in that application will trigger a new build; you can see in the console output if it’s building, and if there are any error messages along the way.
I’m 98.3% certain that a deploy after a build will always cause FPM to restart, which should clear the opcache. Without looking at your project specifically I’m not sure what the issue could be. All of your templates are being compiled at build time, not deploy time, yes?
My app is a typical Symfony one. I didn’t do anything special with how the templates are used/compiled.
I run
cache:clearat build and deploy, just like in your template.I think I’m having the same issue. The twig files files are being regenerated by
cache:clearin my deploy hook. I can see that invar/cache/prodI have the correct version. But the files being served are still the old ones.Same as @quentin-thiaucourt I use
cache:clearin both my hooks as per template.After troubleshooting the issue with the support, commenting out:
# opcache.preload: /app/config/preload.phpSolved the issue. I guess it was called too early and generated the opcache based on the old files?
Please sign in to leave a comment.