Trellis + caching (page and assets)

Hi,
i am not a cache expert, I always used shared hostings in the past, and I started to use DO recently together with trellis/bedrock/sage.

so far so good, I never activated the cache in my previous projects, but now I am going online with a new project (and I think that I will need the cache on this because it will receive a lot of visitors because a social campaign will link to it) so I would like to activate the cache, so I can speed up a little bit and keep the droplet happier.

I read the docs, and as far as I understood, there is the built-in option to activate the page caching.
Do I need to set inside wordpress_sites.yml just the value to true, or I need to paste the whole settings?

cache:
  enabled: false
  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

are these settings ok for the majority of the WordPress websites or I need to be aware of something?

moreover, I would like to active also the caching of assets (so google speed test will be happy), and add the expiry headers, I saw that I can do this, by creating a file cache.conf.j2 inside trellis/nginx-includes/sitename.com/ folder.

are there any recommended settings for this?
is roots.io still using this setting (post of 2017)?

many thanks
M.

Just enabled: true is enough :smile:

Yes, they are designed to be safe defaults for standard WP sites. If you have a WooCommerce site for example you may need more custom skip rules.

are there any recommended settings for this?

Yes that should still work fine. Just keep in mind you need to use a build system (like Sage has for example) which will properly bust the cache by having the hash/version in the filename at least.

thanks @swalkinshaw.

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

are these the default settings?
is the exactly the same as just enabled: true?

regards the expiry headers I thought about this, I am using sage 9, so for the main css/js I will be safe.
what about the others css/js that the plugins include, is there a recommended way to add hash/version also to these files?
if not, because changing these files will be exceptional (just in case of emergency), I can do like old school adding ? at the end to force the browser to download a new version.

thanks again.

Here are the defaults: https://github.com/roots/trellis/blob/bffccba0c248f0445bbd3db89230688ceaf5fea0/roles/wordpress-setup/defaults/main.yml#L30-L33

I don’t really know unfortunately. Depends on how they inject the scripts/styles

if not, because changing these files will be exceptional (just in case of emergency), I can do like old school adding ? at the end to force the browser to download a new version.

Yep that works

thanks again @swalkinshaw :wink:

This topic was automatically closed after 42 days. New replies are no longer allowed.