Skip to content

Enabling Redis Cache

Redis should be used for all caching with exception to Varnish for the FPC in Magento 2 (or customized Varnish uses or Turpentine with Magento 1). Please note that redis-config-cache and redis-session must be turned on in the stratus panel.

Files cache is very BAD!

Magento 2

Use the following commands via CLI:

Redis Cache

php bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=redis-config-cache --cache-backend-redis-db=0 --cache-backend-redis-port=6381

Redis FPC

php bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=0 --page-cache-redis-port=6379

Redis Session

php bin/magento setup:config:set --session-save=redis --session-save-redis-host=redis-session --session-save-redis-log-level=3 --session-save-redis-db=0 --session-save-redis-port=6380

Magento 1

Add this to your Magento local.xml configuration, then flush the cache to apply it.  Note that you can skip the full page block if you are not using Magento 1 EE. Check the developer document for any 3rd party FPC module. Most support Redis. You can enable/disable the redis config cache container under Redis->Config Cache.


ADD FOR FPC ( Enterprise only )

    <server>redis-config-cache</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>0</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) -->