Skip to content

Cache configuration

NOTE: All Magento stores are required to have cache enabled on production AND use Redis for cache storage. We do not allow cache to be stored in files nor in the database. See Magento Requirements for the full list of requirements.

Magento 2

We recommend Redis, if you are using Varnish FPC in Magento 2, you do not need Redis for the page_cache. Add the below into your env.php file to enable Redis cache.

<? php
'cache' =>
   'frontend' =>
      'default' =>
         'backend' => 'Cm_Cache_Backend_Redis',
         'backend_options' =>
            'server' => 'redis',
            'database' => '0',
            'port' => '6379'
    'page_cache' =>
      'backend' => 'Cm_Cache_Backend_Redis',
      'backend_options' =>
         'server' => 'redis',
         'port' => '6379',
         'database' => '1',
         'compress_data' => '1'

Magento 1

Add the configuration below to your local.xml file for Magento 1. The full page cache section only applies for Magento 1 EE. Check the developer document for any 3rd party FPC module. Most support Redis.


Magento 1 ADD FOR FPC ( Enterprise )

    <server>redis</server> <!-- or absolute path to unix socket -->
    <persistent></persistent> <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: -->
    <database>3</database> <!-- Redis database number; protection against accidental data loss is improved by not sharing databases -->
    <password></password> <!-- Specify if your Redis server requires authentication -->
    <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
    <lifetimelimit>57600</lifetimelimit>    <!-- 16 hours of lifetime for cache record -->
    <compress_data>0</compress_data>        <!-- DISABLE compression for EE FPC since it already uses compression -->
    <auto_expire_lifetime>604800</auto_expire_lifetime> <!-- Force an expiry (Enterprise_PageCache will not set one) -->
    <auto_expire_refresh_on_load></auto_expire_refresh_on_load> <!-- Refresh keys when loaded (Keeps cache primed frequently requested resources) -->

Enabling Caches

You can enable caches with the following:

Magento 1 n98-magerun cache:enable

Magento 2 n98-magerun2 cache:enable