PHPackages                             mothership/headless-shopware-varnish-cache - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. mothership/headless-shopware-varnish-cache

ActiveSymfony-bundle[Caching](/categories/caching)

mothership/headless-shopware-varnish-cache
==========================================

Shopware bundle that adds a cache adapter for a varnish for headless shopware

3.0.0(1y ago)71.6k1MITPHPPHP &gt;=8.2

Since Dec 6Pushed 1y ago5 watchersCompare

[ Source](https://github.com/mothership-gmbh/headless-shopware-varnish-cache)[ Packagist](https://packagist.org/packages/mothership/headless-shopware-varnish-cache)[ RSS](/packages/mothership-headless-shopware-varnish-cache/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (0)

Mothership Varnish cache adapter for headless Shopware
======================================================

[](#mothership-varnish-cache-adapter-for-headless-shopware)

This Shopware bundle adds a cache adapter for a varnish for headless shopware.
If activated, it automatically invalidates a varnish cache when a cache-tag gets invalidated in Shopware. Like this, an external frontend application can use an effective full page cache (FPC) together with a headless Shopware backend.

This bundle is meant to be used together with the [corresponding nuxt module](https://github.com/mothership-gmbh/nuxt-shopware-caching) e.g. for Shopware-PWA. Nevertheless, it can be used without the nuxt module, if the headless application sets cache tags in another way.

This currently obviously only works on self-hosted Shopware instances, as you need to be able to install the bundle.

Installation
------------

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require mothership/headless-shopware-varnish-cache
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require mothership/headless-shopware-varnish-cache
```

#### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Mothership\HeadlessShopwareVarnishCacheBundle\HeadlessShopwareVarnishCacheBundle::class => ['all' => true],
];
```

#### Step 3: Configuration

[](#step-3-configuration)

First add the configuration file:

```
# www/config/packages/cache.yml
headless_shopware_varnish_cache:
  enabled: "%env(bool:HEADLESS_VARNISH_ACTIVE)%"
  reverse_proxy:
    hosts: "%env(csv:HEADLESS_VARNISH_HOSTS)%"
    max_parallel_invalidations: 3
    ban_method: "BAN"
    tag_flush_threshold: 100
    use_xkey: true # requires Varnish module xkey
    xkey_chunksize: 50 # optional, default: 50
```

As you can see, two environment variables are used:

- `HEADLESS_VARNISH_ACTIVE`: 1 or 0 to activate/deactivate
- `HEADLESS_VARNISH_HOSTS`: Comma-separated list of varnish hosts, e.g. ","

Example Varnish configuration
-----------------------------

[](#example-varnish-configuration)

See a stripped down example Varnish configuration [here](docs/example.vcl).
There is also an example available which only uses xkeys [here](docs/example_xkeys.vcl).

Disclaimer: this is not a production ready configuration file and stripped down to show the essential parts for the caching solution!

Usage
-----

[](#usage)

After installation and activation the module automatically invalidates the varnish cache at the configured hosts when a cache-tag gets invalidated in Shopware.
For example if a product changes, Shopware by default invalidates a cache-tag for this product. Like this all pages that contain this product get invalidated too and therefore are always up-to-date.

CLI-Command to manually flush the cache
---------------------------------------

[](#cli-command-to-manually-flush-the-cache)

`bin/console varnish:invalidate`

- by default, it flushes the whole cache for all hosts
- --tags : Comma separated tags to clear
- --regex : Regex to match URLs which should be flushed

Flush manually via curl
-----------------------

[](#flush-manually-via-curl)

### Using the xkeys version

[](#using-the-xkeys-version)

UsecaseCommandDescriptionsingle URL`curl -X BAN https://www.domain.de/my/path`Only the specified URL gets flushedwhole domain`curl -X BAN -H 'xkey: all' https://www.domain.de`Flush all URLs on the specified hostsingle cache-tag`curl -X BAN -H 'xkey: product-' https://www.domain.de`Flush all sites (on all hosts) with cache-tag "product-"### Using the custom-header version

[](#using-the-custom-header-version)

UsecaseCommandDescriptionsingle URL`curl -X BAN https://www.domain.de/my/path`Only the specified URL gets flushedwhole host`curl -X BAN -H 'X-Cache-Tags: all' https://www.domain.de`Flush all URLs on the specified hostsingle cache-tag`curl -X BAN -H 'X-Cache-Tags: product-' https://www.domain.de`Flush all sites with cache-tag "product-" on this host

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 69.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~134 days

Total

5

Last Release

715d ago

Major Versions

1.2.0 → 2.0.02023-11-15

2.0.1 → 3.0.02024-05-27

PHP version history (3 changes)1.1.1PHP &gt;=7.4

2.0.0PHP &gt;=8.1

3.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/31ea5c2a7c0f4d9beeb077750260256b4e0836f74b4f194c4bc6a513381b61d9?d=identicon)[Mothership](/maintainers/Mothership)

---

Top Contributors

[![niklaswolf](https://avatars.githubusercontent.com/u/16021919?v=4)](https://github.com/niklaswolf "niklaswolf (16 commits)")[![ts-mothership](https://avatars.githubusercontent.com/u/60600855?v=4)](https://github.com/ts-mothership "ts-mothership (7 commits)")

### Embed Badge

![Health badge](/badges/mothership-headless-shopware-varnish-cache/health.svg)

```
[![Health](https://phpackages.com/badges/mothership-headless-shopware-varnish-cache/health.svg)](https://phpackages.com/packages/mothership-headless-shopware-varnish-cache)
```

###  Alternatives

[predis/predis

A flexible and feature-complete Redis/Valkey client for PHP.

7.8k305.7M2.4k](/packages/predis-predis)[snc/redis-bundle

A Redis bundle for Symfony

1.0k39.4M67](/packages/snc-redis-bundle)[react/cache

Async, Promise-based cache interface for ReactPHP

444112.4M40](/packages/react-cache)[illuminate/cache

The Illuminate Cache package.

12835.6M1.4k](/packages/illuminate-cache)[colinmollenhour/php-redis-session-abstract

A Redis-based session handler with optimistic locking

6325.6M14](/packages/colinmollenhour-php-redis-session-abstract)[shopware/production

178190.0k](/packages/shopware-production)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
