elgentos / magento2-varnish-extended

elgentos/magento2-varnish-extended

This extension extends the built-in Varnish functionalities

magento2-module Compatibility: 2.4.8-2.4.9 Code Quality: Fail Tests: N/A Security: Pass OSL-3.0

VCL Tests

Elgentos_VarnishExtended

This module aims to add some extra features to the Varnish capabilities in Magento.

Configurable tracking parameters

The core Magento VCL contains hard-coded marketing tracking parameters. Almost nobody changes them, but adding tracking parameters often used on your site highly increases hit rate.

This extension adds a field under Stores > Config > System > Full Page Cache > Varnish Configuration > Tracking Parameters in the backend to customize your own parameters.

IMPORTANT NOTE: this is not applied automatically! You need to use the optimized VCL:

bin/magento varnish:vcl:generate --export-version=6 --input-file=vendor/elgentos/magento2-varnish-extended/etc/varnish6.vcl --output-file=/data/web/varnish6.vcl
varnishadm vcl.load new-custom-vcl /data/web/varnish6.vcl
varnishadm vcl.use new-custom-vcl

Marketing Parameters

Info message when removing marketing parameters

Marketing parameters in the URL have a negative effect on the hit rate of the (Varnish) cache. You can list the marketing parameters that Varnish should remove to improve the hit rate.

Don't worry, removing these parameters will not break Magento, because these URL parameters are only processed in your browser, not on the server.

Warning message when a marketing parameter matches our regular expression

Warning: you are trying to remove a marketing parameter from the URL that is also a filterable product attribute in Magento. Are you sure you want to remove it? Removing this parameter may prevent Magento from filtering on that attribute.

Checking the Varnish hit rate

If you use RUMVision and when on Hypernode or Maxcluster, you can view the historical Varnish hit rate in RUMvision.

Otherwise you can do it manually:

wget --quiet https://raw.githubusercontent.com/olivierHa/check_varnish/master/check_varnish.py
chmod +x check_varnish.py
./check_varnish.py -f MAIN.cache_hit,MAIN.cache_miss -r

A good hit-rate for a B2C store is around 80-90%. For B2B, this would be lower, depending on how closed-off your catalog is.

Auto-apply custom VCL

You can place it in your Git repo in app/etc/varnish6.vcl and automate applying it through Deployer on each deploy with the following Deployer task.

desc('Auto-apply VCL when custom VCL exists');
task('vcl:auto-apply', function () {
    if (test('[ -f {{release_path}}/app/etc/varnish6.vcl ]')) {
        $timestamp = date('YmdHis');
        run('{{bin/php}} {{release_path}}/bin/magento varnish:vcl:generate --export-version=6 --input-file={{release_path}}/app/etc/varnish6.vcl --output-file=/data/web/varnish6.vcl');
        run('varnishadm vcl.load vcl' . $timestamp . ' /data/web/varnish6.vcl');
        run('varnishadm vcl.use vcl' . $timestamp);
    }
})->select('stage=production');

Contrary to popular belief, loading & activating ('using') a new VCL does not purge the cache objects already in Varnish. However, the new VCL might change how future requests are processed, which could result in cached items being evicted sooner or fetched differently.

Compatibility

Needs at least Magento 2.4.7 and Varnish 6.4.

If you run into your VCL being generated without curly braces inside for and if directives, please check if you haven't still applied patch MDVA-4344. If you're running a recent Magento version, this patch isn't needed and breaks generation of the VCL.

Running the test suite

The features of the VCL template are covered by a range of automated tests. To run the test suite, simply run make test in the tests/varnish folder:

cd tests/varnish
make test

The make test command will start a Docker container that has all the .vtc files mounted and runs the varnishtest command to run the tests.

This is the equivalent of running the following command in the tests/varnish folder:

varnishtest *.vtc

This will run the entire test suite, but you can also run individual tests by running the following command:

cd tests/varnish
make test_single TEST=purge.vtc

This will only run the tests inside the purge.vtc file, which is the equivalent of running varnishtest purge.vtc.

More information about the varnishtest program can be found on the varnish-cache.org documentation site. You will also find information on the Varnish Test Case syntax.

No changelog yet

The vendor hasn't published a changelog. Tagged releases appear in the Versions tab.

Versions
Version Stability QA Status Compatibility Released
2.0.6 stable Fail Magento 2.4.8-2.4.9 Details 2026-04-01 13:11:41
2.0.5 stable Not tested Not yet tested Details 2026-01-30 13:59:50
2.0.4 stable Not tested Not yet tested Details 2026-01-23 12:51:09
2.0.3 stable Not tested Not yet tested Details 2025-12-21 14:49:04
2.0.2 stable Not tested Not yet tested Details 2025-12-02 12:59:11
2.0.1 stable Not tested Not yet tested Details 2025-10-01 18:47:52
2.0.0 stable Not tested Not yet tested Details 2025-06-13 08:39:21
1.0.0 stable Not tested Not yet tested Details 2024-09-19 13:32:17

Requires 3

Package Constraint
magento/framework >=103.0.7
magento/module-page-cache *
php ^8.3

Compatibility

Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.

Compatibility matrix (Magento × PHP)
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 not tested Pass
2.4.8 Pass Pass
2.4.9 Pass Pass

Code Quality

Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.

Static analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

Static analysis results
Tool Status Findings Summary
PHPCS Warning 23 23 warnings (ruleset: Magento2) — 8 auto-fixable with phpcbf
PHPMD Pass 0
Cpd Pass 0
Composer validate Info 2 valid; 2 advisory notes (composer validate --strict)

PHPStan

Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.

PHPStan results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A 9
2.4.8 8 8
2.4.9 8 8

Tests

Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.

Unit tests

Unit tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Integration tests

Integration tests results by Magento and PHP version
Magento PHP 8.2 PHP 8.3 PHP 8.4 PHP 8.5
2.4.7 N/A N/A
2.4.8 N/A N/A
2.4.9 N/A N/A

Security

Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.

Security results
Tool Status Findings Summary
Composer audit Pass 0
Malware scan Pass 0
License
OSL-3.0

More from elgentos

View vendor
Make it pay

Turn an existing module into recurring revenue.

If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.