Ga naar inhoud

πŸ‡¬πŸ‡§ Enable caching for Trellis

FastCGI caching

FastCGI caching, which is said to be a better choice than Varnish, is build in into Trellis’ configuration. Read more on the Trellis documentation website below πŸ‘‡. FastCGI Caching | Trellis Documentation | Roots


Configuration

  • Check which group_vars section you wish to edit, β€˜production’ or β€˜staging’.
  • Open the group_vars/production/wordpress_sites.yml file (for production)
  • Add the following block
...
cache:
enabled: true
duration: 30s
skip_cache_uri: /wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml
skip_cache_cookie: comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in

Note: the β€˜skip_cache_uri’ is important here. It excludes permalinks from being cached. This is the starting point when you have issues with caching.

Provision the server

  • From the trellis/ folder run:
Terminal window
ansible-playbook server.yml -e env=production --tags=wordpress

This provisions the server with the newly created cache settings.

Using caching with WooCommerce

Read this: https://roots.io/trellis/docs/fastcgi-caching/#woocommerce