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

Viewed 415

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

With the extension manager, the flushing of caches happens automatically when an extension is installed or updated.

Is it recommended to do a (hard) cache flush in some cases, e.g.

  • extension installation
  • extension update
  • extension removal

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

2 Answers

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.

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)

Related