- Download the latest release from the releases page
- Extract the archive to your WordPress
wp-content/plugins/directory asvarnish-cache - Activate the plugin through the WordPress admin panel
Install via Composer using GitHub releases:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Savvii/wp-varnish-cache"
}
],
"require": {
"savvii/wp-varnish-cache": "^0.0.1"
}
}Then run:
composer require savvii/wp-varnish-cacheImportant: When installing via Composer, use tagged releases (e.g., ^0.0.1) instead of dev-main. Release archives automatically exclude development files (tests, CI configuration, etc.) thanks to .gitattributes export-ignore rules.
Activate via WP-CLI:
wp plugin activate varnish-cacheFill in all the admin fields, after filling them in, you will get a sample VCL.
You can add this VCL at /etc/varnish/default.vcl and modify it to your specific needs.
The plugin provides WP-CLI commands for managing Varnish cache:
# FIRST: Set admin fields via WP-CLI
wp option update varnishHost "localhost"
wp option update varnishPort "80"
wp option update varnishBackendHost "localhost"
wp option update varnishBackendPort "7080"
wp option update varnishACL '"127.0.0.1";'
# For multiple ACL entries, use multiple lines separated by newlines:
wp option update varnishACL '"127.0.0.1";\n"192.168.1.1";\n"10.0.0.1";'
# Export VCL to stdout
wp varnish export-vcl
# Export VCL to a file
wp varnish export-vcl --output=/path/to/output.vcl
Note: The ACL setting should be formatted with each IP or hostname in double quotes and suffixed by a semicolon, e.g., '"127.0.0.1";'
This plugin supports ESI for dynamic content fragments. You can wrap any content in [esi]content[/esi] tags, and it will be processed as an ESI include. This allows Varnish to cache different parts of the page separately.
Example:
This content is cached normally.
[esi]This content is cached separately and can have different cache settings.[/esi]
Back to normal cached content.
ESI is particularly useful for:
- Dynamic content that changes frequently
- Content that should be cached for different durations than the rest of the page
Please test this extension on older PHP versions first. This extension will be tested against the latest WordPress version and the lowest non-EOL PHP version. The main reason for this, is that as a hosting, we care about the safety of our customers and their end users. We do try to avoid usage of non-backwards compatible code.
We do not support intelligent bans for block themes yet, you can help achieving this here.
Pull requests are welcome, we provided warden for development. Below are steps the steps to setup an environment:
- Install warden -> https://warden.dev/
- Go to the project root
- Run warden setup-env
Above will launch an env with demo data and configure Varnish automatically.
This project includes several custom Warden commands to streamline development, testing, and environment setup. All commands must be executed within the Warden container (e.g., warden shell). Below is a comprehensive list with descriptions:
| Command | Description |
|---|---|
warden browser-tests |
Runs Pest browser tests (Playwright-based), excluding unit tests. |
warden configure-plugins |
Activates Varnish Cache plugin, installs/configures WooCommerce, imports sample data, sets Varnish/WooCommerce options. |
warden format |
Formats PHP code with Mago. |
warden install-wordpress |
Downloads/installs WordPress core, creates config, sets debug, runs demo reset/plugin config. |
warden lint |
Lints PHP code with Mago. |
warden reload-vcl |
Updates VCL template with backend settings, restarts Varnish. |
warden reset-demo |
Resets demo: cleans DB, reinstalls WP, generates content, assigns terms, installs Storefront theme, creates menu. |
warden setup-env |
Prepares VCL, starts environment, installs Composer/npm deps, signs certs, installs WP if needed. |
warden unit-tests |
Runs Pest unit tests, excluding browser tests. |
warden vcl-tests |
Runs Varnish Test Cases (VTC) with varnishtest. |
For more details on any command, inspect the script in .warden/commands/. Always run formatting, linting and tests before committing changes.
- Admin username and pass?
- user:
admin - pass:
admin
- user:
Create an issue to discuss the implementation. You can make a PR afterwards.