Shopware 6 Cache: HTTP Cache Optimization & Performance
Caching is one of the most important performance factors in Shopware 6. By caching content that has already been calculated, database queries, PHP processes, and server load are significantly reduced. As part of holistic Shopware 6 performance optimization this improves load times, Core Web Vitals and the scalability of the shop considerably.
Introduction to Shopware Cache Optimization
Why Is Caching Important for Shopware?
Caching is one of the most important performance mechanisms in Shopware 6. Frequently requested content is cached so that database queries and PHP processes do not have to be executed again with every page view. This makes pages respond much faster and noticeably reduces server load.
Especially with high traffic, a properly configured caching system prevents unnecessary load spikes and stabilizes the entire shop infrastructure. At the same time, visitors benefit from shorter load times and an overall smoother user experience.
Overview of Cache Strategies in Shopware
Shopware 6 uses several caching layers that perform different tasks. These include the PHP OPcache, the Symfony-based HTTP cache, and external solutions such as Redis or Varnish.
While OPcache keeps compiled PHP files in memory, Redis accelerates database-related processes and sessions. Varnish, in turn, can deliver complete HTTP responses directly without putting additional load on PHP or MySQL.
Only the interaction of these layers enables a scalable and high-performance Shopware architecture.
Impact on Performance
A well-designed cache strategy often reduces the response times of a Shopware shop considerably. Content can be delivered faster, while CPU load, database access, and memory operations decrease at the same time.
In particular, the full-page cache significantly improves Time to First Byte (TTFB), because precomputed content can be delivered directly. This not only has a positive effect on the user experience, but also supports better Core Web Vitals and more stable conversion rates.
See also our guide to Shopware TTFB optimization.
Shopware HTTP Cache
How the HTTP Cache Works
The Shopware HTTP cache, based on the Symfony Reverse Proxy, acts as an intelligent cache that stores complete HTTP responses for certain routes before they are sent to the client’s browser. The cache evaluates HTTP headers such as “Cache-Control” and “ETag” to decide whether a resource needs to be requested again from the backend or can be served from its own storage. In addition, the Symfony-based Reverse Proxy uses Edge Side Includes (ESI) to embed individual dynamic fragments—such as the shopping cart notice—within an otherwise fully cached page. It relieves the PHP backend enormously for recurring requests because the entire Shopware 6 stack does not have to be initialized again.
HTTP Cache Configuration
The HTTP cache in a Shopware 6 shop is configured primarily via the `shopware.yaml` or `config/packages/framework.yaml` file, where developers can precisely define the validity period (TTL – Time to Live) and the routes to be cached. A correct cache strategy includes setting relevant cache tags for products, categories, and Product Streams in order to enable granular invalidation. Shopware’s documentation provides detailed instructions on how to configure this feature optimally for the entire system.
Cache Invalidation and Clearing
Cache invalidation is a central component of the Shopware HTTP cache because it ensures that customers do not see outdated product data, prices, or stock levels. Instead of clearing the entire cache, Shopware 6 works with cache tags to invalidate affected content specifically.
In newer Shopware versions, invalidation is also delayed via Scheduled Tasks and the Message Queue. When products or categories are updated, Shopware does not immediately delete the affected pages from the cache. Instead, they are first marked as “invalid” and then regenerated in the background.
This approach significantly reduces load spikes and, especially in larger shops, ensures more stable cache hit rates as well as consistently lower server loads.
Completely clearing the cache should only be done in exceptional cases, for example after deployments, plugin updates, or major template changes. The classic CLI command is:
bash
php bin/console cache:clearThe cache can then be warmed up again:
bash
php bin/console cache:warmupHowever, automatically clearing the entire cache every day via cronjob is usually not sensible for larger Shopware projects. Especially with extensive product catalogs, rebuilding the full-page cache can take a very long time and temporarily lead to significantly higher server loads.
Optimal Invalidation Intervals
For medium-sized shops with around 10,000 to 50,000 products and regular order volumes, an invalidation interval between 3,600 seconds (1 hour) and 14,400 seconds (4 hours) has proven effective in many projects.
Intervals that are too short create unnecessary database load, while intervals that are too long can cause price changes or stock levels to appear in the frontend with a delay.
The adjustment is made directly via the database:
SQL
UPDATE scheduled_task
SET run_interval = 3600
WHERE name = 'shopware.invalidate_cache';Move Cache Invalidation Out of the Request Cycle
The actual cache invalidation should generally not be processed within the normal HTTP request cycle. If the calculation is performed directly during a user request, noticeable load spikes and increased response times can occur, especially with larger product catalogs.
Instead, execution via dedicated CLI workers and Scheduled Tasks in the background is recommended. This keeps the storefront stable even under high concurrency, while cache recalculation is processed asynchronously.
Scheduled Tasks should therefore be executed via a system cronjob rather than through the browser admin:
bash
bin/console scheduled-task:run --time-limit=240 --memory-limit=512MIn addition, enabling delayed cache invalidation is recommended (from Shopware 6.7 onward):
env
SHOPWARE_HTTP_CACHE_DELAYED_INVALIDATION=1This means cache recalculations are processed asynchronously, which significantly stabilizes response times under high concurrency.
HTTP Cache Lifetime (TTL)
The default TTL of the Shopware HTTP cache is 7,200 seconds (2 hours). Once this period has expired, the page must be completely regenerated the next time it is accessed.
Because Shopware already has an intelligent tagging and invalidation system, it is often advisable in production environments to set the TTL significantly higher.
Up to and including Shopware 6.7, the configuration was handled globally via the .env:
env
Bis Shopware 6.7
# HTTP-Cache aktivieren
SHOPWARE_HTTP_CACHE_ENABLED=1
# Lebensdauer auf 24 Stunden erhöhen (86400 Sekunden)
SHOPWARE_HTTP_DEFAULT_TTL=86400New Cache System from Shopware 6.8
From Shopware 6.8 onward, HTTP caching is fundamentally expanded. Cache lifetime is no longer controlled globally via the .env, but is defined granularly through policies at route and area level.
In addition, Shopware introduces a new opt-out principle. Through the sw-cache-hash cookie, the cache now remains active by default even for logged-in users or filled shopping carts.
Important new Cache-Control directives are:
- s_maxage: Defines the maximum lifetime in the HTTP cache or reverse proxy.
- stale_while_revalidate: Allows stale content to be served while the cache is rebuilt in the background.
- must_revalidate: Forces revalidation in the browser cache.
The configuration is made via shopware.yaml:
yaml
# config/packages/shopware.yaml
shopware:
http_cache:
# 1. Richtlinien definieren
policies:
# Beispiel für eine lange Lebensdauer (z.B. 24 Stunden)
mein_shop_policy:
headers:
cache_control:
public: true
max_age: 0
must_revalidate: true
s_maxage: 86400 # Cache-Lebensdauer in Sekunden (hier 24 Std)
stale_while_revalidate: 86400
stale_if_error: 7200
# 2. Die Richtlinie standardmäßig zuweisen
default_policies:
storefront:
cacheable: mein_shop_policyVarnish Cache and Its Role
What does Varnish do for Shopware? Varnish acts as an HTTP reverse proxy in front of the web server. It serves static content and HTML pages directly from RAM without putting load on PHP or MySQL. This drastically lowers TTFB and protects the system from load spikes.
Setting Up Varnish for Shopware
Setting up Varnish as a reverse proxy in front of Shopware 6 requires precise configuration of the VCL (Varnish Configuration Language). Varnish processes incoming HTTP requests before the actual Shopware backend and decides whether content can be served directly from the cache or must be forwarded to PHP and the web server.
Typically, static assets and complete HTML pages are cached, while dynamic areas such as checkout, customer account, or shopping cart must be excluded from caching. In addition, cache tags, purge requests, and ESI blocks play an important role in clean cache invalidation.
A correctly configured VCL significantly reduces backend load, and therefore memory access and CPU usage, while improving the scalability and load time of the shop.
Example of a Simple Varnish VCL
The specific Varnish configuration always depends heavily on the infrastructure, plugins in use, individual session logic, and the shop’s traffic profile. Nevertheless, the following example shows a typical basic configuration for Shopware 6:
VCL
sub vcl_recv {
# Kein Cache für Checkout und Kundenkonto
if (req.url ~ "^/checkout" ||
req.url ~ "^/account" ||
req.url ~ "^/widgets") {
return (pass);
}
# Nur GET und HEAD cachen
if (req.method != "GET" &&
req.method != "HEAD") {
return (pass);
}
return (hash);
}
sub vcl_backend_response {
# Standard TTL
set beresp.ttl = 24h;
}In production Shopware environments, individual rules are also often implemented for the following areas:
- Cache tags
- PURGE requests
- ESI blocks
- Cookies
- Shopping cart handling
- GeoIP logic
- Personalized content
- Bot traffic
- CDN integration
Especially in larger Shopware projects, the VCL should therefore always be tailored individually to the infrastructure, hosting setup, and plugin landscape.
Reverse Proxy Cache: Advantages and Challenges
Especially for shops with high traffic, the internal Shopware HTTP cache sooner or later reaches its limits. In such scenarios, Varnish becomes particularly relevant because requests are processed before PHP processes or database queries are even generated.
This significantly reduces both server load and response times. Particularly on heavily visited category or product pages, Varnish can achieve considerably better cache hit rates.
The biggest challenge, however, lies in cache invalidation. Changes to products, prices, or CMS content must be communicated specifically to Varnish via purge requests or cache tags so that no outdated content is served.
To handle these cache invalidation challenges in live operation, a perfectly coordinated web server setup is essential. Dedicated Shopware Hosting Optimization ensures that Varnish purges are processed without delay. Particularly on heavily visited category or product pages, Varnish can achieve considerably better cache hit rates. However, correctly implementing the complex invalidation logic requires deep system expertise. As a certified Shopware agency our developers handle error-free VCL customization. If you are unsure where your system is currently losing loading speed, we identify all hidden caching bottlenecks as part of a strategic analysis and consulting .
Cache Statistics and Monitoring
Effective monitoring of Varnish cache statistics is essential for evaluating caching efficiency and identifying potential bottlenecks. Tools such as `varnishstat` or integrations with monitoring solutions such as Prometheus provide detailed insights into cache hits, misses, and evictions, revealing the actual level of optimization. This data enables shop operators and developers to continuously optimize the VCL configuration and adapt the cache strategy to the specific requirements of the Shopware shop.
Important Note on Shopware 6 Versions in Connection with Varnish
- Shopware 6.5 (The Legacy Architecture): In this version, Varnish primarily acts as an add-on layer. Cache invalidations are resource-intensive and performed via BAN requests using regular expressions (RegEx) through Redis or the database. With large product updates, this leads to measurable CPU load spikes on the Varnish server.
- Shopware 6.7 (The Performance Quantum Leap): With version 6.7, the architecture was completely redesigned. The Varnish xkey module is now mandatory and resolves item tags within microseconds. Together with natively enforced Edge Side Includes (ESI), static content and dynamic fragments (such as the shopping cart) are cleanly separated.
– The result: Official benchmarks show up to 108% more processed orders per second in simulated flash sales and a reduction in server latency (p99) of up to 58%. - Shopware 6.8 (The Enterprise Stabilization): While 6.7 introduced the new system, 6.8 adds the final refinements. The system introduced behind the CACHE_REWORK feature flag in 6.7 becomes the standard here. Version 6.8 minimizes the dreaded “over-invalidation” (the unintended clearing of the entire cache during simple backend configuration changes) and sustainably stabilizes the cache hit rate in live operation.
These improvements also change the required Shopware Varnish configurations. The VCL must therefore be adjusted accordingly beforehand.
Redis as Object Cache
As an in-memory database, Redis moves volatile cache data and PHP sessions out of the slow file system into RAM. This prevents I/O bottlenecks and massively accelerates Shopware systems with 10,000 products or more
Configuring Redis in Shopware 6
In many large Shopware projects, Redis is used to significantly reduce database queries and session locks. Especially under high concurrency, file-system-based session handling quickly reaches its limits. Configuration is performed via `config/packages/shopware.yaml`, where the Redis adapter for caching and sessions is defined, typically with a DSN such as `redis://localhost:6379`. A properly implemented Redis setup significantly increases the speed of the Shopware shop.
Example of a Redis Configuration for Shopware 6
For Shopware 6, Redis is often used both as an object cache and for sessions. A typical Redis integration in shopware.yaml can, for example, look like this:
yaml
shopware:
cache:
invalidation:
delay: 3600
framework:
cache:
app: cache.adapter.redis
default_redis_provider: 'redis://127.0.0.1:6379'
session:
handler_id: Redis
save_path: "tcp://127.0.0.1:6379"It is important to never run Redis in production environments without a memory limit. Without a defined maxmemory setting, Redis can consume all available server memory under high load or faulty cache invalidations.
A typical basic configuration in redis.conf can, for example, look like this:
INI
maxmemory 2gb
maxmemory-policy allkeys-lruThe allkeys-lru strategy ensures that older cache entries are automatically removed as soon as the defined memory limit is reached.
The optimal memory size depends heavily on the size of the shop as well as the following factors:
- Number of products
- Concurrent users
- Session volume
- Plugins in use
- HTTP cache hit rate
- Number of Sales Channels
Especially in larger Shopware projects, the Redis configuration should therefore be monitored regularly and adjusted to the actual load.
Redis Sessions and Their Optimization
Moving PHP sessions to Redis relieves the server’s file system and accelerates the processing of user requests, especially under high traffic, which massively improves system scalability. By default, PHP stores sessions on disk, which leads to I/O bottlenecks with many concurrent users; Redis provides fast access times here. This optimization is crucial for shops with 10,000 or more simultaneous visitors.
Comparison Between Redis and Varnish
While Redis acts as an object cache and for sessions at the application level and accelerates database-related queries, Varnish functions as a reverse proxy HTTP cache at network level that serves complete pages. Redis accelerates Shopware’s backend processing, while Varnish minimizes the number of requests to the backend. Both technologies complement each other; Varnish serves the “fast” cache for static content and Redis the “dynamic” cache for cached data.
Full Page Cache and Cache Warmup
Implementing the Full Page Cache
The full page cache in Shopware 6, often implemented in combination with Varnish or the Symfony HTTP cache, stores fully rendered HTML pages for specific routes in order to enable extremely fast delivery for recurring requests without renewed PHP processing. This intensive caching strategy is particularly effective for non-personalized content such as product listings or category pages. Configuration is handled via HTTP headers as well as the ESI and cache tags integrated into Shopware.
Effects on Core Web Vitals
An effective full page cache implementation and precise cache warmup strategies have a direct and significant impact on Core Web Vitals by drastically improving Largest Contentful Paint (LCP) and First Input Delay (FID) values.
By providing pre-generated content, server response times are minimized and rendering speed is increased, resulting in a better user experience and a positive assessment by search engines.
Scaling Large Shops
Reducing Database Load Through Caching
Caching significantly relieves the database in large Shopware shops by eliminating the need for repeated, resource-intensive database queries, because frequently requested data is served from the faster cache. Object caches such as Redis keep product, category, and configuration data in memory, reducing the number of SQL queries. This is crucial for shops with large volumes of data and complex relationships because it ensures speed and stability.
Optimizing Server Load
Through comprehensive use of HTTP caches, reverse proxies such as Varnish, and object caches such as Redis, PHP utilization and overall server load in Shopware 6 environments are significantly reduced. Cached content minimizes the number of requests reaching the PHP backend, which means fewer CPU cycles and less memory need to be allocated. This optimization allows the shop to withstand high traffic while guaranteeing fast load times.
Example Architecture of a Shopware Cluster for High Availability and Maximum Performance
- 2 load balancers
- 2 Varnish servers
- 2 Elasticsearch/Redis servers
- 2 web servers
- 2 MySQL servers (e.g. Galera Cluster or primary/primary replication)
- Separate backup system
- Optional: File server/NAS for the shared media folder
- Optional: Backend/administration server
It is important that all production systems—with the exception of the backup server—communicate via internal network connections. Ideally, this is done via a separate internal network or a second network card. Alternatively, all systems should at least be located in the same local network segment so that communication takes place without additional router hops. This reduces latency and improves overall performance .
Backup Strategy
The optimal backup strategy depends heavily on order volume and the frequency of changes to product data.
For medium-sized Shopware shops, the following intervals have proven effective:
- Database backups: every 2 hours during the day, every 6 hours at night (retention: 7 days)
- Files/Webroot/Media: 2× daily (retention: 30 days)
- Infrastructure configurations (e.g. load balancer/Varnish): after changes, plus a monthly backup.

In practice, a consistent backup of the database and web/media data is usually fully sufficient. Services such as Redis, Varnish, or Elasticsearch normally do not need to be backed up separately because their data is automatically rebuilt or synchronized after a restart.
Hosting Options: Shopware Cloud vs. Own Server
The choice between Shopware Cloud and your own server has a major influence on the scalability and cache optimization of a Shopware shop. The cloud provides preconfigured, often automatically scaling caching solutions, while your own server offers full control over every cache layer and the infrastructure. Shopware Cloud manages the infrastructure and caching automatically, reducing administrative effort. Your own server, however, offers the flexibility to tailor Redis, Varnish, and OPcache precisely to specific requirements, which is essential for maximum optimization.
Best Practices for Cache Optimization
For effective cache optimization in Shopware 6, it is advisable to implement a multi-layer cache strategy combining Redis as an object cache, Varnish as a full page cache, and the Shopware HTTP cache. Setting precise cache tags for granular invalidation, automating cache warmup processes via cronjobs, and regularly monitoring cache statistics ensure consistently high speed. Reduce PHP processing and database queries through consistent caching.
Monitoring and Analysis
Tools for Monitoring Cache Performance
Continuous monitoring of cache performance is essential in order to identify bottlenecks early and ensure the long-term stability of a Shopware system. Especially in larger shops with high concurrency, proper monitoring often determines whether a shop remains stable and performant under load.
Different tools are used depending on the infrastructure in place.
Varnish Monitoring with varnishstat
The most important analysis tool for Varnish is varnishstat. It provides real-time information on cache hits, misses, backend requests, memory consumption, and queue utilization.
Particularly relevant metrics are:
| Value | Meaning |
|---|---|
cache_hit | Request could be served directly from the Varnish cache |
cache_miss | Content had to be reloaded from the backend |
backend_fail | Backend was unreachable or returned errors |
n_lru_nuked | Old cache objects had to be removed due to insufficient memory |
threads_failed | Varnish could not create new worker threads |
A typical command:
bash
varnishstat -1For production Shopware systems, persistently low cache hit rates are usually considered a warning signal. If the hit rate remains below 50% (up to Shopware 6.6.x) / 70% (from Shopware 6.7 onward), this often indicates the following problems:
- Incorrectly configured cookies
- Unnecessary
return(pass)rules - Overly aggressive cache invalidations
- Missing xkey soft purges
- Plugins with personalized content
Especially on heavily visited category pages, cache hit rates well above 90% should be achievable.
Analysis of HTTP Headers
Many cache problems can already be analyzed directly in the browser. Using the developer tools (F12) HTTP headers can be checked.
Important headers in Shopware/Varnish environments:
| Header | Meaning |
|---|---|
x-cache | HIT or MISS in Varnish |
cache-control | Defines TTL and cache rules |
sw-cache-hash | Shopware cache context |
xkey | Assigned cache tags |
age | Age of the cache object |
A typical example:
html
x-cache: HIT
cache-control: public, s-maxage=86400
age: 5321This means:
- Page was successfully served from Varnish
- TTL is 24 hours
- Object has already been in the cache for 5321 seconds
- With a small adjustment in the Varnish
default.vclthe number of hits can also be displayed
vcl
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Cache = "HIT";
set resp.http.X-Cache-Hits = obj.hits;
} else {
set resp.http.X-Cache = "MISS";
}
}If, on the other hand, MISS appears constantly even though the page should be cacheable, there is usually a cookie, session, or proxy problem.
Redis Monitoring and Memory Analysis
Redis should be monitored regularly for memory consumption, evictions, and response times.
Important commands:
bash
redis-cli info memoryshows, among other things:
- current RAM consumption
- maxmemory limits
- fragmentation
- evicted keys
Equally important:
bash
redis-cli info statsThe following critical values, among others, can be identified here:
| Value | Meaning |
|---|---|
evicted_keys | Number of keys deleted due to insufficient memory |
keyspace_hits | successful cache accesses |
keyspace_misses | failed cache accesses |
Rising evicted_keys are usually a clear sign that:
- the
maxmemorysetting was chosen too small - sessions and cache are operated together
- the wrong eviction policy is active
Especially with Shopware, Redis should never be allowed to grow without limits.
Monitoring PHP OPcache
PHP OPcache is also one of the most important performance factors in Shopware 6.
The current status can, for example, be read via:
bash
php -i | grep opcacheor via small status scripts.
Critical metrics:
| Value | Meaning |
|---|---|
opcache_hit_rate | OPcache hit rate |
memory_consumption | used shared memory |
wasted_memory | fragmented memory |
num_cached_scripts | cached PHP files |
Especially in large Shopware installations with many plugins, it often happens that:
opcache.max_accelerated_filesis set too low- scripts are constantly reloaded
- the hit rate drops sharply
In production environments, the OPcache hit rate should remain close to 100% over the long term.
Long-Term Monitoring with Prometheus & Grafana
For larger Shopware clusters, centralized monitoring via the following is also recommended:
- Prometheus
- Grafana
- Netdata
- Zabbix
- Datadog
- New Relic
- check_mk
This allows the following values, among others, to be visualized continuously:
- Cache hit rates
- Redis RAM utilization
- MySQL query times
- PHP-FPM utilization
- Queue runtimes
- TTFB
- Varnish backend fetches
- Web server CPU load
Historical comparisons after the following are particularly helpful:
- Deployments
- Plugin updates
- Shopware updates
- Marketing campaigns
- Black Friday load spikes
This often makes it possible to identify performance problems before customers notice them.
Typical Practical Monitoring Problems
Recurring patterns often emerge in real Shopware projects:
Suddenly Falling Cache Hit Rate
Often caused by:
- new plugins
- tracking scripts
- incorrectly set cookies
- session starts on every page
High Redis Evictions
Frequently caused by:
- missing
maxmemory - shared use for sessions and cache
- the wrong eviction policy
Varnish Backend Fetch Spikes
Typical causes:
- missing cache warming
- hard purges instead of soft purges
- TTLs that are too short
- faulty invalidation
High TTFB Despite Varnish
Usually caused by:
- uncached AJAX requests
- slow Elasticsearch queries
- blocking plugins
- overloaded MySQL servers
Professional monitoring makes it possible to identify such problems early and take targeted countermeasures before the shop’s performance or stability suffers.
FAQ: Typical Cache Problems and Cache Optimization
The most common questions about cache strategies in Shopware 6 include aspects such as “Which caches are relevant for my shop?”, “How do I prevent outdated content?”, and “How do I scale caching under high traffic?”. Shop operators and developers often look for best practices for configuring Redis, Varnish, and the HTTP cache, as well as methods for effective invalidation and cache warmup. These questions focus on optimizing load times and reducing server load.
Why can the wrong Redis eviction policy bring Shopware 6 to a standstill?
If Redis is operated with the default noeviction policy, Shopware can no longer write new cache entries when the cache memory is full. This can cause severe performance problems and even complete storefront outages. For volatile cache data, the volatile-lru policy is therefore recommended so that older entries can be removed automatically.
Redis: Why should the Shopware cache and sessions not reside in the same Redis instance?
If volatile cache data and persistent sessions are stored together in one Redis instance, important shopping cart or session keys can be deleted under memory pressure. This often leads to checkout abandonment or lost customer sessions. For production Shopware environments, it is therefore advisable to separate cache and session data into separate Redis instances or different databases with their own memory rules.
Redis: Why can Redis persistence reduce Shopware performance?
If persistence functions such as RDB snapshots or Append-Only Files (AOF) are enabled for pure Shopware cache instances, Redis must additionally persist write operations to disk. This creates unnecessary I/O latency and noticeably reduces cache performance. For volatile HTTP and application caches, it is therefore advisable to disable persistence in Redis.
Settings in redis.conf
ini
Disable RDB snapshots
save ""
Disable Append Only File
appendonly noappendonly no and save ““ completely disable disk persistence.- This configuration should only be used for volatile cache data.
- Ideally, operate sessions/shopping carts on a separate Redis instance.
Why is cache:clear often not sufficient in Shopware 6?
The CLI command php bin/console cache:clear often clears only the local Symfony file-system cache. External cache systems such as Redis or Varnish, however, continue to retain their data in memory. This can result in outdated content, prices, or cache inconsistencies. In production Shopware environments, HTTP cache invalidations, Redis clears, or targeted Varnish purges should therefore also be performed.
Why is cache warming important after a cache clear?
If the Shopware cache is cleared after updates or deployments, pages and data first have to be regenerated completely. Without cache warming, the first page view often has significantly longer load times because Shopware calculates and compiles content live from the database. The cache should therefore be warmed automatically after a clear via cache:warmup or background workers.
Varnish: Why should Varnish configuration only be carried out with sufficient expertise?
An incorrect Varnish configuration can cause personalized content or customer sessions to be cached unintentionally. In the worst case, visitors may see other users’ shopping carts, customer data, or account information. Session cookies and dynamic Shopware areas must therefore be consistently excluded from the HTTP cache. For production systems, only current Shopware VCL templates, tested cache rules, and a clean invalidation strategy should be used. For more complex Shopware infrastructures, configuration by experienced administrators or specialized Shopware hosting partners is recommended.
Varnish: “503 Backend Fetch Failed” Due to Header Limits
Shopware’s extended cache tagging can make HTTP headers (e.g. X-Cache-Tags or xkey) very large. If Varnish’s standard buffers are insufficient, backend communication fails with a “503 Backend Fetch Failed”.
In production Shopware environments, the parameters http_resp_hdr_len and http_resp_size should therefore usually be increased to 64k to 128k.
Varnish: Missing or Faulty Cache Invalidation
For changes to products, prices, or stock levels to appear correctly in the frontend, Shopware must be able to send invalidation requests to Varnish. If the reverse proxy settings are missing or IP addresses or ports are configured incorrectly, outdated content remains in the cache despite backend changes.
Varnish: Incorrect Trusted Proxies Configuration
If Varnish runs as a reverse proxy in front of Apache or Nginx, Shopware must trust the proxy. If the configuration via TRUSTED_PROXIES is missing, Symfony no longer recognizes the visitor’s real IP address and sees only the IP address of the Varnish server.
As a result, Geo-IP analysis, security rules, or rate limits often no longer work correctly. In addition, all orders appear in the Shopware backend with the same IP address.
Therefore, add the IP address or internal network of your Varnish server to .env.local as a trusted proxy:
env # Lokaler Varnish TRUSTED_PROXIES=127.0.0.1,::1 # Separater Varnish-Server TRUSTED_PROXIES=192.168.1.50 # Docker-/dynamische Netzwerke TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR
In addition, Varnish must pass on the original client IP via X-Forwarded-For. Apache or Nginx must also process these headers correctly so that Shopware recognizes the actual customer IP.
Varnish: Missing Soft Purges Cause Unnecessary Load Spikes
Without XKey support, Varnish often immediately removes complete pages from the cache (“Hard Purge”) when products change. The next visitor then has to have the page fully regenerated via PHP and the database, which leads to significantly higher load times, especially under high traffic.
For production Shopware environments, using soft purges via the xkey module is therefore recommended. Cache content initially remains available while Varnish updates the affected pages in the background.
To do this, enable the mod_xkey module in Varnish and set the following in the Shopware configuration:
YAML shopware: http_cache: reverse_proxy: use_varnish_xkey: true
Especially in larger Shopware projects with many product changes, this significantly improves the cache hit rate and greatly reduces load spikes after cache invalidations.
OPcache: Insufficient Shared Memory Slows Down Shopware
Together with Symfony, Composer dependencies, and plugins, Shopware 6 loads tens of thousands of PHP files. If the available OPcache memory is undersized, PHP cannot keep many precompiled scripts permanently in shared memory and has to reload them regularly from disk.
Especially in larger Shopware installations, this noticeably increases load times and Time to First Byte (TTFB). Default values of 64 MB or 128 MB are usually no longer sufficient for production systems.
For production Shopware environments, a significantly higher memory allocation in php.ini is therefore recommended:
opcache.memory_consumption=512
Smaller shops can often already be operated stably with 256 MB. For larger plugin landscapes, multiple Sales Channels, or enterprise hosting environments, however, 512 MB or more is often advisable.
OPcache: max_accelerated_files Value Too Low
Together with Symfony, Composer dependencies, and installed plugins, Shopware 6 often consists of several tens of thousands of PHP files. If the maximum number of cacheable files in OPcache is set too low, PHP can no longer keep many classes in shared memory.
As soon as the limit is reached, parts of the shop fall out of the cache and must be reloaded from disk and compiled again. This significantly increases Time to First Byte (TTFB), especially in heavily visited shops.
The default values of many hosting environments—often only 10000 files—are usually no longer sufficient for modern Shopware installations.
For production Shopware systems, a significantly higher configuration in php.ini is therefore recommended:
opcache.max_accelerated_files=60000
Larger enterprise installations in particular, with many plugins, custom extensions, or multiple Sales Channels, benefit noticeably from more stable load times and optimized PHP performance.
OPcache: File Validation Enabled in Production (opcache.validate_timestamps)
In many standard hosting environments, opcache.validate_timestamps=1 is enabled. As a result, PHP checks on every single request whether PHP files on disk have changed.
This is barely noticeable in small projects—but in larger Shopware installations with tens of thousands of files, plugins, and Symfony components, it creates considerable additional I/O load on the file system. The result is unnecessarily longer load times and a worse Time to First Byte (TTFB).
For production Shopware systems, it is therefore advisable to disable automatic file validation:
opcache.validate_timestamps=0
This keeps compiled PHP files permanently in OPcache shared memory so they do not have to be checked again on every page view. High-performance Shopware enterprise hosting environments in particular benefit noticeably from this under high load and many parallel requests.
Important: After Shopware updates, plugin installations, or deployments, OPcache must then be cleared manually—for example via a PHP-FPM reload or opcache_reset()—otherwise changes will not become active immediately.
OPcache: Interned Strings Buffer Too Small
By default, opcache.interned_strings_buffer is limited to just 4 MB or 8 MB in many PHP installations. For modern Shopware and Symfony applications, this value is often far too low.
Shopware 6 uses thousands of recurring strings—for example class names, namespaces, service container entries, or configuration keys. If the shared interned strings memory is insufficient, identical strings have to be stored multiple times per PHP process in memory.
Especially under high load, this leads to unnecessarily increasing RAM consumption and inefficient memory usage across the entire web server.
For production Shopware environments, increasing the value to at least 16 MB, preferably 32 MB, is therefore recommended:
opcache.interned_strings_buffer=32
Larger Shopware installations in particular, with many plugins, Composer dependencies, and extensive Symfony containers, benefit from significantly more efficient shared-memory usage and more stable performance under load.
Elasticsearch: Too Many or Too Small Shards (“Oversharding”)
Each Elasticsearch shard requires its own memory, CPU resources, and cluster management overhead. If too many small shards are used, overhead increases significantly and the performance of the entire search cluster noticeably deteriorates.
Especially in larger Shopware installations, many small indexes often lead to higher heap usage, longer search times, and unstable cluster states. Instead of accelerating search, oversharding creates additional load on all Elasticsearch nodes.
For production Shopware environments, a sensible shard size of around 10 GB to 50 GB per shard is therefore recommended. Small product catalogs often require significantly fewer shards than is commonly assumed by default.
In addition, old or rarely used indexes should be optimized or merged regularly—for example via Index Lifecycle Management (ILM). This keeps heap utilization, cluster state, and search performance stable over the long term.
Elasticsearch: Incorrect Java Heap Memory Configuration
Error: The Elasticsearch Java heap is either undersized or exceeds the critical threshold of around 32 GB. This results either in OutOfMemory errors or significant performance losses due to disabled “Compressed OOPs”.
Impact: A heap that is too small leads to instability under load, slow search queries, or complete crashes of the Elasticsearch cluster. A heap that is too large, on the other hand, worsens JVM memory addressing and reduces performance despite higher RAM allocation.
Solution: Set Xms and Xmx identically in jvm.options to around 50% of the available memory, but no more than 30–31 GB. The remaining RAM should be available to the operating system for the file-system cache, as Elasticsearch benefits greatly from it.
bash # Beispiel für 64 GB RAM -Xms30g -Xmx30g
Especially in large Shopware installations with Elasticsearch, Redis, and Varnish, correct memory allocation is a key factor in stability and search performance. For complex cluster or high-traffic environments, professional infrastructure planning by an experienced Shopware hosting partner is recommended.
How can cache performance be tested in Shopware 6?
Cache performance in Shopware 6 can be reliably tested with various analysis and load-testing tools. Particularly important metrics include load times, Time to First Byte (TTFB), cache hit rate, and stability under high load.
For initial performance analyses, tools such as Google Lighthouse, GTmetrix, or WebPageTest are suitable. These measure Core Web Vitals, rendering times, and server response times, among other things. A comparison between a “cold cache” (directly after clearing the cache) and a “warm cache” is useful.
For technical cache analysis, additional tools can be used:
- varnishstat and varnishlog for monitoring Varnish hit rates and backend requests
bash
Varnish: Echtzeit-Statistiken anzeigen
varnishstat
Nur wichtige Cache-Metriken filtern
varnishstat -f MAIN.cache_hit,MAIN.cache_miss,MAIN.backend_fail
Cache-Hit-Rate live beobachten
watch -n1 "varnishstat -f MAIN.cache_hit,MAIN.cache_miss"
Backend-Fehler analysieren
varnishstat -f MAIN.fetch_failed,MAIN.backend_busy
Varnish: HTTP-Requests und Cache-Verhalten analysieren
varnishlog
Nur Cache-Hits anzeigen
varnishlog -g request -q "RespHeader:x-cache ~ hit"
Nur Cache-Misses anzeigen
varnishlog -g request -q "RespHeader:x-cache ~ miss"
Fehlerhafte Backend-Requests filtern
varnishlog -g request -q "BerespStatus >= 500"
Requests einer bestimmten URL analysieren
varnishlog -g request -q 'ReqURL ~ "/kategorie/"'- redis-cli info for analyzing memory consumption, evictions, and Redis hits
bash
Redis: Allgemeine Server- und Cache-Informationen
redis-cli INFO
Nur Speicherinformationen anzeigen
redis-cli INFO memory
Cache-Hit-Rate prüfen
redis-cli INFO stats
Speicherbelegung live überwachen
watch -n1 'redis-cli INFO memory | grep used_memory_human'
Aktuelle Eviction-Policy prüfen
redis-cli CONFIG GET maxmemory-policy
Anzahl gelöschter Keys durch Speicherknappheit prüfen
redis-cli INFO stats | grep evicted_keys
Alle aktiven Keys zählen
redis-cli DBSIZE
Langsame Redis-Operationen anzeigen
redis-cli SLOWLOG GET 10For Shopware, the following are particularly relevant:- cache_hit vs. cache_miss in Varnish
- evicted_keys in Redis
- high backend_fail values
- unusually high RAM consumption
- increasing TTFB despite an active cache
- Browser developer tools for checking HTTP headers such as x-cache, cache-control, or age
- Load tests with ApacheBench (ab), wrk, or Apache JMeter to simulate high visitor volumes
Which caches are relevant for my shop?
For maximum performance and stable load times, a professional Shopware setup combines several coordinated cache layers. Which of these are useful depends on shop size, traffic, and infrastructure. Especially for larger Shopware installations with many products or high visitor volumes, the combination of HTTP cache, Redis, PHP OPcache, and optionally Varnish is recommended.
The most important cache layers at a glance
HTTP Cache (Full Page Cache)
The integrated Shopware HTTP cache stores already rendered pages such as categories, product pages, or Shopping Experiences. This means these contents do not have to be generated again from the database and templates on every page view.Advantages:
- Significantly reduced server load
- Faster load times and better TTFB
- Fewer database accesses
Redis (Object & Session Cache)
Redis replaces slow file-based caching and stores data directly in memory (RAM). Sessions, shopping carts, and cache objects benefit in particular.Typical use cases:
- Sessions & shopping carts
- Symfony/Shopware cache
- Locking & Message Queues
conf
maxmemory 2gb
maxmemory-policy volatile-lru
appendonly no
save ""PHP OPcache
OPcache stores already compiled PHP code in RAM. This means PHP does not have to interpret files again on every request.Recommended settings for Shopware 6:
ini
opcache.memory_consumption=512
opcache.max_accelerated_files=60000
opcache.interned_strings_buffer=32
opcache.validate_timestamps=0Especially in Shopware 6 with many plugins, a properly configured OPcache significantly reduces CPU load.Varnish Cache (optional)
Varnish acts as an upstream reverse proxy in front of the web server and answers HTTP requests directly from memory—even before PHP or Shopware is executed at all.This is particularly relevant for:
- high visitor volumes
- load spikes (Black Friday, TV campaigns)
- large product catalogs
bash
varnishstat -1 | grep cache_hit
varnishlog -g request -q "ReqUrl ~ /"Which combination makes sense?
| Shop size | Recommendation |
|---|---|
| Small shops | HTTP cache + OPcache |
| Medium-sized shops | HTTP cache + Redis + OPcache |
| Large shops / Enterprise | Redis + OPcache + Varnish + dedicated cache clusters |
- separate Redis instances
- centralized cache invalidation
- Varnish XKey soft purges
- horizontal scaling via load balancers
How do I scale caching under high traffic?
With very high visitor volumes—for example during Black Friday, TV campaigns, or major discount promotions—the load must be consistently shifted away from CPU and disks toward memory (RAM) and dedicated cache systems.
Professional Shopware architectures combine several separate cache layers for this purpose.
1. Varnish as an Upstream HTTP Reverse Proxy
The integrated Shopware HTTP cache continues to run through PHP processes. Under high load, this can quickly become a bottleneck because even cache hits place load on the web server.
The solution is to use an upstream Varnish cache. Varnish serves cached pages directly from memory—even before Shopware or PHP is processed at all.
Depending on the shop structure, this can often keep more than 80–90% of all requests completely away from the backend. Category, product, and CMS pages in particular benefit massively from this relief.
2. Move Sessions and Application Cache to Redis
Without Redis, Shopware stores large quantities of small cache files directly on the file system. Under high load, this quickly creates I/O bottlenecks on SSD or NVMe storage.
It is therefore recommended to separate these into multiple Redis instances:
Redis instance for the Shopware application cache
Separate Redis instance for sessions and shopping carts
This separates critical session data from volatile cache data, and all read and write access takes place directly in RAM instead of on disk.
conf maxmemory 4gb maxmemory-policy volatile-lru appendonly no save ""
3. Horizontal Scaling Across Multiple Web Servers
In enterprise setups, multiple Shopware web servers are also operated behind a load balancer. Varnish and Redis act as the central cache layer in front of the actual application servers.
This architecture enables:
stable load times despite load spikes
significantly lower database load
better scalability during campaigns
higher availability
Especially in large Shopware projects, the right cache architecture has a decisive impact on stability, conversion rate, and server costs.
