Varnish Cache Purge for Magento 2

Compatibility
2.4.9, 2.4.8, 2.4.7, 2.4.6, 2.4.5, 2.4.4, 2.4.3, 2.4.2, 2.4.1, 2.4.0, 2.3.7, 2.3.6, 2.3.5, 2.3.4
€15.38
per item
Email to a Friend

Enquire about this product

Description / Varnish Cache Purge for Magento 2

MAGENTO 2 · VARNISH · CACHE · MULTISTORE

Connect Flush Cache Storage to Varnish cache invalidation.

Kowal Purge Varnish Cache

After the action in the Magento panel, the module collects store domains and runs local ban commands for them. Organize content refresh in infrastructure with correctly configured Varnish access.

Domains from configuration · Ban per host · Operation logs

HOW IT WORKS IN PRACTICE

01 · Verify the Varnish environment
Check the administration tool and process permissions.

02 · Run the panel action
Flush Cache Storage triggers the module's observer.

03 · Domains receive the ban command
Check the logs and page freshness.

How does your store benefit?

Explore the module's features, use cases, and settings.

Faster store refresh after changes in Magento 2

Kowal_PurgeVarnishCache is a lightweight Magento 2 module that automates Varnish cache invalidation when cache is cleared from the administration panel. Store changes become visible faster, without manually logging into the server or additional operations by the technical team.

What this module provides

  • automatically triggers Varnish cache clearing after the action Flush Cache Storage in the Magento panel,
  • collects the domains of all stores configured in Magento and performs a ban for each,
  • reduces the risk of stale content after deployments, CMS changes, price updates or configuration changes,
  • simplifies daily work for administrators, marketers and e-commerce teams.

Faster publication of changes

New content, corrections and offer updates can become visible to customers faster, without waiting for manual infrastructure operations.

Fewer operational errors

Cache refresh is linked to the natural Magento workflow, reducing the risk of missing a purge after store changes.

Support for multistore environments

The module uses store domains defined in Magento, fitting architectures with multiple storefronts.

Better collaboration between business and IT

Business teams can work faster, and IT does not have to perform repetitive administration tasks after every change requiring a cache refresh.

Who it is for

The module is particularly suitable for Magento 2 projects that:

  • use Varnish as an HTTP cache layer,
  • frequently publish changes to content, promotions and configuration,
  • operate in multistore mode or across multiple domains,
  • want to reduce manual DevOps or server administration tasks.

How it works

When cache clearing is started in the Magento administration panel, the module listens for the system event and executes the command varnishadm ban for domains collected from store configuration. This means faster Varnish cache invalidation without leaving the standard Magento panel.

Summary

Kowal_PurgeVarnishCache is a practical extension for teams that want convenient Magento 2 operation with greater control over the freshness of content served by Varnish. It simplifies the process, reduces response time and helps maintain a consistent shopping experience after store changes.

Infrastructure requirements

The current code uses /usr/bin/varnishadm, /etc/varnish/secret and the local administration interface 127.0.0.1:6082. These values are hardcoded, without a connection configuration form.

The PHP process must be able to run exec, read the required file and connect to the Varnish interface. A remote server, containers or different paths require adapting the integration.

Trigger and invalidation scope

The observer is assigned to adminhtml_cache_flush_all in the adminhtml area. It runs after Flush Cache Storage; simply saving a product, CMS page or configuration does not trigger this observer.

The module collects unique hosts from Store View base URLs and performs a ban using req.http.host. The scope covers the domain, rather than only a page or tag of the changed entity.

Confirming the result and subsequent requests

The code logs command success, a nonzero result or an exception through the Magento logger. Checking logs distinguishes the panel action from a successful Varnish ban.

The module does not warm the cache after the operation. Subsequent requests can rebuild responses; other cache layers and their configuration still affect when customers see a change.

Installation via Composer

Package kowal/module-purgevarnishcache, module Kowal_PurgeVarnishCache. After configuring access to the Kowal repository, install the package, enable the module, update Magento, and clear the cache. In production, include compilation and static content deployment in accordance with the store's deployment process.

From configuration to results

1. Verify the Varnish environment
Check the administration tool and process permissions.

2. Run the panel action
Flush Cache Storage triggers the module's observer.

3. Domains receive the ban command
Check the logs and page freshness.

Publishing CMS changes in multistore

After changing content, the administrator runs Flush Cache Storage. The module performs a ban for unique hosts collected from store configuration.

With correct local Varnish access, subsequent requests can fetch refreshed content. The command result and any errors go to the Magento logger.

Adapt cache refresh to your infrastructure

Want to tailor the module to your store? Ask about implementing Kowal Purge Varnish Cache and discuss the configuration or any extensions you need.

More Information

Theme compatibility Luma / Blank, KOWAL

Module Installation Instructions

Installation via Composer

You will receive the access details for the Composer repository, the customer's email address and license token, by email after purchase. They are also available in the customer panel after logging in at kowal.store. Replace TWOJ_EMAIL_KLIENTA with your account email address and TWOJ_TOKEN with the token you received. Run the commands in the Magento root directory.

composer config repositories.kowal composer https://repo.kowal.store
composer config http-basic.repo.kowal.store "TWOJ_EMAIL_KLIENTA" "TWOJ_TOKEN"
composer require kowal/module-purgevarnishcache

Completing the installation

After installing the package, run the Magento update and clear the cache:

php bin/magento setup:upgrade
php bin/magento cache:flush

In a production environment, also run DI compilation and deploy static files according to your store deployment process.

Press to skip carousel

We found other products you might like!

Write Your Own Review
You're reviewing: Varnish Cache Purge for Magento 2
Your Rating:
Price
Quality
Support
loader
Loading...

You submitted your review for moderation.

Update cookie preferences