leocolomb / wp-acorn-cache
A cache manager powered by Laravel through Acorn.
Requires
- php: ^8.0
- composer/installers: ^v1.0|^v2.0
- koodimonni/composer-dropin-installer: ^1.3
Requires (Dev)
- pestphp/pest: ^v1.20
- pestphp/pest-plugin-mock: ^v1.0
- roots/acorn: ^v2.0.0-beta.2
- squizlabs/php_codesniffer: ^3.5
README
Warning
🚧 This project is still rather experimental.
Most probably not functional out of the box and definitely not ready for production.
About
This plugin provides cache handlers for WordPress, using Acorn framework based on Laravel fondation.
- Enables the two cache wrappers for WordPress using drop-ins.
- Object Cache (
object-cache.php
) - Advanced Page Cache (optional) (
advanced-cache.php
)
- Object Cache (
- Compatible with any driver supported by Laravel (including Redis, Memcached and Array).
- Adds handy WP-CLI commands.
- Targets modern software stacks.
Usage
-
Prepare your Composer file by adding custom paths.
Replace<wordpress-root/wp-content/>
with your WordPress content path,web/app/
with Bedrock.
See more info.{ "extra": { "dropin-paths": { "<wordpress-root/wp-content/>": [ "package:leocolomb/wp-acorn-cache:dropins/object-cache.php", "package:leocolomb/wp-acorn-cache:dropins/advanced-cache.php" ] } } }
-
Require the installer and allow its usage.
composer require koodimonni/composer-dropin-installer
-
Require the package in your Composer-managed WordPress instance.
composer require leocolomb/wp-acorn-cache
Object Cache
The WordPress Object Cache is used to save on trips to the database. The Object Cache stores all of the cache data to memory and makes the cache contents available by using a key, which is used to name and later retrieve the cache contents.
Driver (recommended)
The cache driver must be setup as per Laravel documentation.
When using Bedrock as WordPress boilerplate, specify the driver
in your .env
file.
CACHE_DRIVER=redis
Configuration (optional)
Object cache behavior can be configured with its appropriate config file, config/object-cache.php
.
Start by publishing the configuration file using Acorn.
wp acorn vendor:publish --provider="LeoColomb\WPAcornCache\Providers\AcornCacheServiceProvider"
Page Cache
With Page Caching, you cache the full output of a page (i.e. the response) and bypass WordPress entirely on subsequent requests.
Note: The page cache is using Symfony HttpCache. While quite efficient, you should prefer using an appropriate page cache tool, like Varnish, Nginx cache or a CDN.
Activation (optional)
Page cache is not activated per default with WordPress.
To enable page cache, define the constant WP_CACHE
to true
.
Configuration (optional)
Page cache behavior can be configured with its appropriate config file, config/page-cache.php
.
Start by publishing the configuration file using Acorn.
wp acorn vendor:publish --provider="LeoColomb\WPAcornCache\Providers\AcornCacheServiceProvider"
License
ISC © Léo Colombaro