cancel
Showing results for 
Search instead for 
Did you mean: 

Full page cache with redis

Full page cache with redis

What should your env.php file look like with full page cache and session storage? I try to configure the way the online doc show and get site not working.

9 REPLIES 9

Re: Full page cache with redis

Here is a working env.php file with regards to using Redis for M2 cache, FPC, and sessions utilizing two Redis instances on ports 6379 and 6380:

  'session' => 
  array (
    'save' => 'redis',
    'redis' => 
    array (
      'host' => '127.0.0.1',
      'port' => '6379',
      'password' => '',
      'timeout' => '2.5',
      'persistent_identifier' => '',
      'database' => '2',
      'compression_threshold' => '2048',
      'compression_library' => 'gzip',
      'log_level' => '1',
      'max_concurrency' => '6',
      'break_after_frontend' => '5',
      'break_after_adminhtml' => '30',
      'first_lifetime' => '600',
      'bot_first_lifetime' => '60',
      'bot_lifetime' => '7200',
      'disable_locking' => '0',
      'min_lifetime' => '60',
      'max_lifetime' => '2592000',
    ),
  ),
  'resource' => 
  array (
    'default_setup' => 
    array (
      'connection' => 'default',
    ),
  ),
  'x-frame-options' => 'SAMEORIGIN',
  'MAGE_MODE' => 'production',
  'cache_types' => 
  array (
    'config' => 1,
    'layout' => 1,
    'block_html' => 1,
    'collections' => 1,
    'reflection' => 1,
    'db_ddl' => 1,
    'eav' => 1,
    'full_page' => 1,
    'config_integration' => 1,
    'config_integration_api' => 1,
    'target_rule' => 1,
    'translate' => 1,
    'config_webservice' => 1,
    'customer_notification' => 1,
    'compiled_config' => 1,
  ),
  'system' => 
  array (
    'default' => 
    array (
      'dev' => 
      array (
        'debug' => 
        array (
          'debug_logging' => '0',
        ),
      ),
    ),
  ),
  'cache' => 
  array (
    'frontend' => 
    array (
      'default' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'port' => '6380',
        ),
      ),
      'page_cache' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'port' => '6380',
          'database' => '1',
          'compress_data' => '0',
        ),
      ),
    ),
  ),

Re: Full page cache with redis

can you put your whole env.php file, I put mine like your but for one server, but still getting page isn't working

Re: Full page cache with redis

Hi @bigd46

 

Below is the full env.php file - with redis  block 

 

<?php
return array (
  'backend' => 
  array (
    'frontName' => 'admin',
  ),
  'db' => 
  array (
    'connection' => 
    array (
      'indexer' => 
      array (
        'host' => 'localhost',
        'dbname' => 'db-name',
        'username' => 'db-username',
        'password' => 'password',
        'active' => '1',
        'persistent' => NULL,
        'model' => 'mysql4',
        'engine' => 'innodb',
        'initStatements' => 'SET NAMES utf8;',
      ),
      'default' => 
      array (
        'host' => 'localhost',
        'dbname' => 'db-name',
        'username' => 'db-password',
        'password' => 'tAH2rpjxwj4cbT',
        'active' => '1',
        'model' => 'mysql4',
        'engine' => 'innodb',
        'initStatements' => 'SET NAMES utf8;',
      ),
    ),
    'table_prefix' => '',
  ),
  'crypt' => 
  array (
    'key' => '0805f34deb9fbce406d4f3ac6cf8e15211111',
  ),
  'resource' => 
  array (
    'default_setup' => 
    array (
      'connection' => 'default',
    ),
  ),
  'x-frame-options' => 'SAMEORIGIN',
  'MAGE_MODE' => 'production',
  'session' => 
  array (
    'save' => 'redis',
    'redis' => 
    array (
      'host' => '127.0.0.1',
      'port' => '6379',
      'password' => '',
      'timeout' => '2.5',
      'persistent_identifier' => '',
      'database' => '2',
      'compression_threshold' => '2048',
      'compression_library' => 'gzip',
      'log_level' => '3',
      'max_concurrency' => '6',
      'break_after_frontend' => '5',
      'break_after_adminhtml' => '30',
      'first_lifetime' => '600',
      'bot_first_lifetime' => '60',
      'bot_lifetime' => '7200',
      'disable_locking' => '0',
      'min_lifetime' => '60',
      'max_lifetime' => '2592000',
    ),
  ),
  'cache_types' => 
  array (
    'config' => 1,
    'layout' => 1,
    'block_html' => 1,
    'collections' => 1,
    'reflection' => 1,
    'db_ddl' => 1,
    'eav' => 1,
    'customer_notification' => 1,
    'config_integration' => 1,
    'config_integration_api' => 1,
    'target_rule' => 1,
    'full_page' => 1,
    'translate' => 1,
    'config_webservice' => 1,
    'compiled_config' => 1,
    'amasty_shopby' => 1,
  ),
  'install' => 
  array (
    'date' => 'Wed, 14 Mar 2018 11:47:14 +0000',
  ),
  'system' => 
  array (
    'default' => 
    array (
      'dev' => 
      array (
        'debug' => 
        array (
          'debug_logging' => '0',
        ),
      ),
    ),
  ),
  'cache' => 
  array (
    'frontend' => 
    array (
      'default' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'database' => '0',
          'port' => '6379',
        ),
      ),
      'page_cache' => 
      array (
        'backend' => 'Cm_Cache_Backend_Redis',
        'backend_options' => 
        array (
          'server' => '127.0.0.1',
          'database' => '1',
          'port' => '6379',
          'compress_data' => '0',
        ),
      ),
    ),
  ),
);

let me know if you have still any issue on this !!

 

Hope it helps 

if issue solved,Click Kudos & Accept as Solution

Re: Full page cache with redis

Nope doesn't work still get page isn't working. put everything in it.

Re: Full page cache with redis

Hi @bigd46

 

open your bootstrap.php file from your magento2/app/ directory and then uncomment this line #ini_set('display_errors', 1); by removing # and then check it will print errors on your browser.

 

then check error on browser what is showing ! 

if issue solved,Click Kudos & Accept as Solution

Re: Full page cache with redis

Fatal error: Uncaught CredisException: Connection to Redis 127.0.0.1:6379 failed after 2 failures.Last Error : (13) Permission denied in /var/www/html/magento/vendor/colinmollenhour/credis/Client.php:463 Stack trace: #0 /var/www/html/magento/vendor/colinmollenhour/credis/Client.php(459): Credis_Client->connect() #1 /var/www/html/magento/vendor/colinmollenhour/credis/Client.php(792): Credis_Client->connect() #2 /var/www/html/magento/vendor/colinmollenhour/credis/Client.php(619): Credis_Client->__call('select', Array) #3 /var/www/html/magento/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(369): Credis_Client->select(1) #4 /var/www/html/magento/vendor/colinmollenhour/cache-backend-redis/Cm/Cache/Backend/Redis.php(242): Cm_Cache_Backend_Redis->_applyClientOptions(Object(Credis_Client)) #5 /var/www/html/magento/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_Redis->__construct(Array) #6 /var/www/html/magento/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache: in /var/www/html/magento/vendor/colinmollenhour/credis/Client.php on line 463

Re: Full page cache with redis

Hi @bigd46

 

That's the issue - as per the error log - it showing that your application is not able to connect with Redis server - where you have installed Redis.

 

Still below i am adding possible two solution for you try one by one !!

 

Might be Your original "bind 0.0.0.0" line got changed to "bind 127.0.0.1". Change that back - that might fix the issue.

 

Second thing refer this github link solution - https://github.com/magenx/Magento-Automated-Server-Configuration-from-MagenX/issues/67

 

Make sure you restart the redis after doing any changes !!

 

 if previous post is helpful then click on kudos Hope it helps !!

if issue solved,Click Kudos & Accept as Solution

Re: Full page cache with redis

Make sure that you have Redis properly installed & running and that it is listening to port 6379.

Re: Full page cache with redis

I have not figured this out yet, saving for later. I have other thing to work on my magento site