Skip to content

Magento 2 extension which interfaces with the Varnish® caching application in order to manage it through the Magento backend.

License

Notifications You must be signed in to change notification settings

jetrails/magento2-varnish

Repository files navigation

Magento 2 - Varnish

Magento 2 extension which interfaces with the Varnish® caching application in order to manage it through the Magento backend.

About

This module helps manage varnish Cache™ for your Magento 2 store. It supports a multiple varnish server configuration. Purge requests can be sent to all these servers in order to purge a specific URL, a specific Magento tag, custom ban rule, or simply to purge all the cache that is contained in said varnish server. Cache exclusion rules can be set to not cache paths or Magento routes. Finally, there exists a debug mode that will display if Varnish FPC was used in loading the page and which exclusion rules should be blamed if the page is excluded.

Documentation

The user manual can be found here. The information there goes over all the features that the extension offers. It also takes you through the installation and configuration process of setting this extension up.

Build System

A simple Makefile is used for this purpose. It is very easy to use and to get a full list of commands and their descriptions, then run the following command:

$ make help

Here are some of the more useful use-cases:

# Replace version number with latest git tag value
$ make bump
# Replace version with specified value
$ make VERSION=1.0.0 bump
# Package with version being latest git tag value
$ make package
# Package with version being manually specified
$ make VERSION=1.0.0 package

Development Environment

We use a super simple development environment that is ephemeral. You can spin it up by doing the following:

mkdir -p ./private/varnish
cp conf/varnish/*.vcl ./private/varnish
docker compose up -d
docker compose logs -f
docker compose down # destroy environment

You can deploy the module into the development environment by running the following:

make clean
make build
make deploy

You can then access the magento container by running the following:

docker compose exec magento bash

Once in the container you can run the standard commands to install the module:

magento setup:upgrade
magento setup:di:compile

The Magento site is hosted on http://localhost and the backend can be reached at http://localhost/admin. Default user name is jetrails and default password is magento2.

Legal Disclaimer

Varnish is a registered trademark of Varnish Software AB and its affiliates.