Shopware App Cache with Redis

The App Cache defines the default cache adapter for Shopware. Shopware stores the App Cache on the file system. If the store experiences a high volume of traffic, this behavior can lead to performance issues. The Linux-based in-memory service Redis provides a solution.

The following section describes how to configure Redis as the cache adapter for all Shopware caches.


Preparation in Shopware

First, a Redis server must be set up for the server. This can be set up either locally on the application server or externally, e.g., via an accelerator server. You can find more information about our accelerator servers here: https://www.creoline.com/de/products/redis-server



Configuration via the Shopware Environment Configuration

Create a new configuration file at the following path: config/packages/framework.yaml. This configuration file is used to configure the app cache. Then insert the following content into the file:

framework:
    cache:
 app: cache.adapter.redis_tag_aware
        default_redis_provider: 'redis://%env(REDIS_HOST_APP_CACHE)%:%env(REDIS_PORT_APP_CACHE)%/%env(REDIS_DB_APP_CACHE)%'


Starting with Shopware 6.6

framework:
    cache:
 app: cache.adapter.redis_tag_aware
 system: cache.adapter.redis_tag_aware
        default_redis_provider: 'redis://%env(REDIS_HOST_APP_CACHE)%:%env(REDIS_PORT_APP_CACHE)%/%env(REDIS_DB_APP_CACHE)%'


The following environment variables are used in this configuration file:

Variable Description
REDIS_HOST_APP_CACHE Hostname or IP address of the Redis server
REDIS_PORT_APP_CACHE TCP port for Redis connections (default: 6379)
REDIS_DB_APP_CACHE Redis database for the app cache


The variables used here must then be added to Shopware’s .env.local environment configuration file. To do this, open the .env.local file in the Shopware root directory and add the following section to the existing configuration:

# .env.local

# [...]

# HTTP Cache Configuration
REDIS_HOST_APP_CACHE=127.0.0.1
REDIS_HOST_APP_CACHE=6379
REDIS_DB_APP_CACHE=1


Then save the file and clear the Shopware cache via the console:

bin/console cache:clear


The Redis server will then be used to manage the app cache.



Shopware provides additional information and adapters in its official documentation.

Go to the Shopware documentation →