Flushing cache during deployment on production system in TYPO3 (Composer based installation)
Asked Answered
A

2

6

With a Composer-based TYPO3 installation (in production), when is it necessary to flush caches, and how to do it?

With a non-Composer installation + using the "Extension Manager", the flushing of caches happens automatically when an extension is installed or updated.

What is the equivalent on the command line when updating / deploying?

Is it recommended to do a (hard) cache flush in some (all) cases?

Also, what is the equivalent of doing a flush cache operation in Maintenance mode ("Install Tool") from the command line (including opcache flush)?


Example deployment workflow (this may be done with some tool, such as deployer)

  • fetch git repository
  • composer install --no-dev
  • ... other commands to flush cash, update DB schema etc.
Aegean answered 15/4, 2021 at 7:17 Comment(6)
Your question is not fully clear, are you talking about a dev environment? Then check also our additional packages github.com/TYPO3-Console/composer-auto-commands and maybe github.com/TYPO3-Console/composer-typo3-auto-install. On a production server cache flushing is normally done during the deployment and not really related to Composer.Breeks
@Simon Thanks for the advice - I updated the question. I meant in production on a Composer based setup.Aegean
I plan on using deployer but assume the use of deployment tool shouldn't really be the issue here.Aegean
@Simon From reading the description github.com/TYPO3-Console/composer-typo3-auto-install I don't understand what it does and what it has to do with cache flushing. I have already installed helhum/typo3_console, helhum/dotenv-connector, gordalina/cachetool. Not sure if or why I need these other tools.Aegean
Cache flushing is done with composer-auto-commands but only on dev environments. So if you call composer with --no-dev this part is not executed. Check github.com/TYPO3-Console/composer-auto-commands/blob/master/src/… for more information. You could include this commands also as scripts like suggested below.Breeks
The other package helps in setting up your local dev environment, maybe we won't provide more updates for this package, not sure at the moment. I like it and use it for all my demos e.g. see the here github.com/GsTYPO3/typo3-introduction#readmeBreeks
S
3

Have a look at this extension: https://packagist.org/packages/helhum/typo3-console it allows you to execute commands on your typo3 installations programmatically including one called cache:flush

You can then utilize composer hooks like post-autoload-dump to execute this command. So it might look something like this in your composer.json:

"scripts": {
  "post-autoload-dump": [
    "typo3cms install:generatepackagestates",
    "typo3cms install:fixfolderstructure",
    "typo3cms install:extensionsetupifpossible"
    "typo3cms cache:flush"
  ]
}

I can't tell you if it's recommended though as I don't run composer on my production server.

Stryker answered 15/4, 2021 at 10:4 Comment(2)
Yes, I am using typo3_console. I wasn't sure if the cache:flush also flushes opcache - same as in install tool.Aegean
Hi, thank you for your answer. To keep this helpful for others, it might be good to add the TYPO3 version(s) for which this applies. Also to add an updated variant for newer TYPO3 versions. If you would be so kind to update your answer, that would be great. If not, I will probably find some time next year to do it. (it might also help to add link to official documentation)Aegean
M
1

If you add the extensions through composer, but still install (enable) them in the TYPO3 Extension Manager or using typo3_console, the cache will still be automatically flushed. For updated extensions, or if you install the extensions directly in PackageStates.php (through git for example) it is recommended to flush the cache and do a database compare (or extension setup).

As crs says in his answer, you can flush the cache with the typo3_console extension. You can even specify which caches you want to flush using cache:flushcache. You can also do a database compare with that extension from the command line using database:updateschema or extension setup using extension:setupactive (which does the database changes and default configuration for active extensions)

Maccarthy answered 22/4, 2021 at 11:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.