Symfony / Empty and regenerate the cache of OPcache

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 :slight_smile:

Most of that is covered in our PHP Tuning guide, here:

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.yaml like so:

variables:
    php: 
        'opcache.validate_timestamps': 0

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 :slight_smile:

I setup things like that, but I find myself having to redeploy, because deployments seems to be using the previous file versions :confused:

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.

Could it be a case of not triggering a new build, just a deploy

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:clear at build and deploy, just like in your template.