Persist the FacetWP Cache db.php drop-in across Trellis deploys.
The add-on needs a db.php drop-in in WP_CONTENT_DIR, so it can answer cached requests before WordPress loads.
It only creates that file when the plugin is activated, as a symlink into one specific release.
Every Trellis deploy builds a fresh release without it, and the old symlink dangles once that release is pruned.
Caching therefore stops after each deploy.
Before the share step of each deploy, if the new release contains the add-on:
- Copies the add-on's
db.phptoshared/facetwp-cache-db.php, replacing it every deploy so plugin updates carry over. - Appends a
db.phpentry toproject_shared_children, so Trellis symlinks the shared file into the release asweb/app/db.php.
Sites without the add-on are left alone.
- Trellis with the
deploy_share_beforehook (roles/deploy/tasks/share.yml) - Bedrock
- The FacetWP Cache add-on installed at
web/app/plugins/facetwp-cache
The add-on's db.php finds cache.php through WP_CONTENT_DIR, not its own location, so the copy works from shared/.
Only one db.php can exist.
If another plugin provides one (for example Query Monitor in development), this role will replace it in deployed releases, so do not install such plugins on those environments.
Add this role to galaxy.yml:
# galaxy.yml
- src: itinerisltd.trellis_facetwp_cache
version: x.x.x # Check for latest version!Install it:
trellis galaxy installAdd the role to the deploy_share_before hook:
# group_vars/all/deploy-hooks.yml
# Learn more on https://roots.io/trellis/docs/deployments/#hooks
deploy_share_before:
- "{{ playbook_dir }}/vendor/roles/itinerisltd.trellis_facetwp_cache/tasks/main.yml"If the hook already exists, add the line to its list.
The role must run in deploy_share_before.
Trellis creates a missing shared file empty, so running later would leave an empty db.php that caches nothing.
The shared file is replaced before the new release goes live.
The live release briefly uses the new db.php with its older plugin code, and a failed deploy or rollback does not restore the previous file.
The file is a short loader, so this is harmless in practice.
If a site sets project_shared_children under its own wordpress_sites entry, Trellis ignores the global variable and the role cannot append to it.
The role fails with a message unless that list already contains the entry below.
Add it to the site's own list, or remove the override:
- path: "{{ project_public_path }}/app/db.php"
src: facetwp-cache-db.php
type: file
mode: '0644'ansible-playbook -i 'localhost,' -c local tests/test.ymltrellis-facetwp-cache is an Itineris Limited project created by Lee Hanbury-Pickett.
Special thanks to the Roots team whose Trellis makes this project possible.
Please submit an issue with anything you do or do not like, or fork the project and make suggestions.
trellis-facetwp-cache is released under the MIT License.