Logo Knowledge
  • Product Documentation
  • Insight
  • Developer Center
  • Training
  • Submit a Request
  • Product Documentation
  • Insight
  • Developer Center
  • Training
  • Submit a Request
  1. Acquia Support Knowledge Base
  2. Troubleshooting
  3. Known Issues

Drupal 8: Twig cache

    See more
    • Updated
    • January 22, 2020 10:42

    Issue

    In Drupal 8, what if my theme does not render as expected?

    Resolution

    Twig Cache

    Twig is used for Drupal 8 theming, and it relies on having its own cache of compiled Twig templates, which is separate from other caches that are cleared with the drush cr all command in Drupal 8. Drupal 8 websites on Acquia Cloud Enterprise can run into issues where cached Twig templates fall out of sync on different web server instances when changes to themes are being made and a code deployment has been performed. When you make changes to themes in Drupal 8 websites on Acquia Cloud Enterprise, connect to each web server instance and run a command like this, to remove the outdated Twig templates:

    drush @[sitename].[prod] --uri=http://[site_URL]/ ev '\Drupal\Core\PhpStorage\PhpStorageFactory::get("twig")->deleteAll();'

    This workaround can temporarily be automated via a mix of Cloud Hooks and Cloud API's https://cloudapi.acquia.com/#GET__sites__site_envs__env_servers__server-instance_route

     

    Cause

    The problem arises from having separate copies of the compiled Twig templates on each web server instance and (the related Drupal core issue https://www.drupal.org/node/2752961 ).

    More information can be found in our product documentation on Known issues in Acquia Cloud.

    Acquia Cloud has a script that will clear twig caches when code is deployed to Acquia Cloud, but this may not resolve this problem in all cases. 

    If your volume is filling due to twig cache files: 

    • Consider adding a scheduled (cron) task to automate the clearing of twig template files on a regular interval.  Use the above drush command as a starting point. 
    • Spend some time with twig debugging tools to better understand why your theme files are generating large numbers of twig cache files.  

     

    Acquia Products

    • Acquia Cloud

    Topics

    • drupal8
    • cache
    • theme
    • twig

    External Links

    • https://cloudapi.acquia.com/#GET__sites__site_envs__env_servers__server-instance_route
    • Known issues in Acquia Cloud
    • No reliable method exists for clearing the Twig cache
    Avatar
    Stacy Wray
    • January 22, 2020 10:42
    • Updated
    • Facebook
    • Twitter
    • LinkedIn

    Was this article helpful?
    2 out of 3 found this helpful

    Return to top

    Related articles

    • Debugging Twig
    • Drupal session cookie attributes
    • Configuration management in Drupal 8
    • Resolving "Not acceptable format: json" error (HTTP code 406) in batch operations
    • Upgrading your database(s) to MySQL 5.7

    Support

    Acquia Support Knowledge Base
    • Submit a Request
    • Contact Support
    • Acquia Support Guide
    • Product Documentation
    • System Status

    About Acquia

    • About Us
    • Leadership
    • Board of directors
    • Newsroom
    • Careers
    • Customers
    • Contact Us
    53 State Street, 10th Floor
    Boston, MA 02109
    United States
    Phone: 888-922-7842
    Map: Google Maps
    View other locations
    • Feeds
    • Legal
    • Security Issue?

    Copyright © 2018 Acquia Inc. All Rights Reserved. Drupal is a registered trademark of Dries Buytaert.