This project uses DDEV for local development and manual testing in an isolated WordPress environment.
composer install
mkdir -p wp && ddev start
ddev exec wp core download --path=/var/www/html/wp
ddev exec wp config create --path=/var/www/html/wp --dbname=db --dbuser=db --dbpass=db
ddev exec wp core install --path=/var/www/html/wp --url=https://batcache.ddev.site --title=Batcache --admin_user=admin --admin_password=admin --admin_email=admin@example.com --skip-email
ddev exec wp plugin activate batcache --path=/var/www/html/wp- DDEV – ddev.com (includes Docker)
- Composer – getcomposer.org
- Install PHP dependencies (optional, for lint/static analysis):
composer install- Create the WordPress docroot and start DDEV:
mkdir -p wp
ddev start- Install WordPress in
wp/(first time only):
ddev exec wp core download --path=/var/www/html/wp
ddev exec wp config create --path=/var/www/html/wp --dbname=db --dbuser=db --dbpass=db
ddev exec wp core install --path=/var/www/html/wp --url=https://batcache.ddev.site --title=Batcache --admin_user=admin --admin_password=admin --admin_email=admin@example.com --skip-email
ddev exec wp plugin activate batcache --path=/var/www/html/wp
# Optional: install Redis Object Cache for Batcache backend (requires Redis, see below)
ddev exec wp plugin install redis-cache --path=/var/www/html/wp --activateThe plugin (this repo) is mounted at wp/wp-content/plugins/batcache via .ddev/docker-compose.plugin.yaml.
There are no automated unit tests. Verify Batcache manually:
-
Object cache required. Ensure an object cache backend is running (e.g. Redis with Redis Object Cache plugin) and that Batcache’s
advanced-cache.phpdrop-in is in place andWP_CACHEis set. See Redis or Memcached below. -
Cache serving. Load a public page (e.g. the homepage) several times. View the page source: just above the
</head>closing tag you should see Batcache stats (e.g. generation time, cache hit). See the main readme for details. -
Cache invalidation. With the optional
batcache.phpplugin active, publish or update a post and confirm the relevant URLs are no longer served from cache (or are regenerated) as expected. -
Redis/Memcached. If using Redis Object Cache, run
ddev exec wp redis status --path=/var/www/html/wpto confirm the connection. Exercise the site in the browser and in WP-CLI to ensure no errors.
ddev start # Start
ddev stop # StopWhen DDEV is running, the site is available at https://batcache.ddev.site (or the URL shown by ddev describe).
Default admin credentials (after wp core install above): admin / admin.
Batcache needs an object cache backend (e.g. Redis Object Cache). DDEV supports Redis via an add-on.
- Add the Redis service and install the plugin:
# Add Redis container
ddev get ddev/ddev-redis
ddev restart
# Install and activate Redis Object Cache plugin (WP-CLI)
ddev exec wp plugin install redis-cache --path=/var/www/html/wp --activate
# Enable the object cache drop-in
ddev exec wp redis enable --path=/var/www/html/wp- Configure wp-config for Redis. WordPress must know the Redis host and have the cache constant set. In DDEV, add these to
wp/wp-config-ddev.php(or towp-config.phpafter the block that includes it):
define( 'WP_REDIS_HOST', 'ddev-batcache-redis' );
define( 'WP_CACHE', true );The host name is ddev-<projectname>-redis (here batcache). If you edit wp-config-ddev.php, note that DDEV may overwrite it; remove the #ddev-generated comment at the top if you want to keep your changes, or put these defines in wp-config.php instead.
- Check status:
ddev exec wp redis status --path=/var/www/html/wp
To disable the object cache (e.g. for imports or WP-CLI batch jobs): ddev exec wp redis disable --path=/var/www/html/wp.
If a Memcached add-on is available, install it and use a Memcached object cache plugin; configure it to use the service (e.g. memcached:11211).
.ddev/config.yaml– DDEV project config (WordPress, docrootwp, PHP 8.3).ddev/docker-compose.plugin.yaml– Mounts the repo aswp/wp-content/plugins/batcache
DDEV not installed: Install DDEV (Docker is required).
ddev start fails (e.g. docroot missing): Ensure wp/ exists: mkdir -p wp. If WordPress is not in wp/ yet, run the wp core download and wp config create / wp core install steps above.
Batcache not serving cached pages: Ensure WP_CACHE is true, advanced-cache.php is in wp-content/, and an object cache (e.g. Redis with Redis Object Cache) is installed and enabled.