Information for: DEVELOPERS   PARTNERS   SUPPORT

Twig caches

Acquia’s require line sets a per-environment temporary directory location for compiled Twig templates.

Cloud Platform stores all Twig caches for all websites hosted in an environment in the following directory:

/mnt/tmp/[SITENAME]/php_storage/twig/[GITREF]/[DATABASE_ROLE]
  • [SITENAME]: Your application’s sitename.
  • [GITREF]: The Git reference of the branch or tag deployed to an environment.
  • [DATABASE_ROLE]: A website-specific identifier, based on the database.

Separating Twig caches by commit and website allows Cloud Platform to purge unused Twig cache directories, preventing them from filling up ephemeral storage on busy infrastructure that frequently deploy code requiring many Twig cache files.

Cloud Platform limits maximum request time to 600 seconds. Outdated Twig cache directories are removed 700 seconds after a code deployment completes, ensuring no active processes still need access to older Twig cache directories.

Altering Twig cache directories

Note

The following instructions should not be attempted on environments running on Acquia Cloud Next.

To alter the Twig cache storage directory, overwrite the value for $settings['php_storage']['twig']['directory'] in your application’s sites/default/settings.php file after the Acquia settings require line, as shown in the following example:

// On Cloud Platform, this include file configures Drupal to use the correct
// database in each site environment (Dev, Stage, or Prod). To use this
// settings.php for development on your local workstation, set $db_url
// (Drupal 5 or 6) or $databases (Drupal 7 or 8) as described in comments
   above.
if (file_exists('/var/www/site-php')) {
    require('/var/www/site-php/mysite/mysite-settings.inc');
}
$settings['php_storage']['twig']['directory'] = '/mnt/tmp/mysite/php_storage/twig';

Twig caches with Site Factory-hosted sites

This feature requires versions 8.x-1.59 or later, or 8.x-2.59 or later, of the Site Factory Connector module.

Twig caches for the websites hosted by Site Factory are stored in an environment in the following directory:

/mnt/tmp/[SITENAME]/php_storage/twig/[GITREF]/[DATABASE_ROLE]

The Acquia Cloud-provided Twig cache directory location can’t be overridden by the Drupal 8 Acquia Cloud Site Factory Connector module.