My question is to Magento Pros:
Can I use Varnish and Redis for FPC (Full Page Cache) at the same time?
My current setup looks like this:
SSL termination > Varnish Full Page Cache > Apache > two Magento 2 websites.
In addition to the setup above I installed Redis for Page Cache to see if I will get any benefit from it.
What confused me is this line in Redis config:
'page_cache' =>
array(
 'backend' => 'Cm_Cache_Backend_Redis',
and here is the full code of sample Redis config I got from Magento official website:
 'cache' =>
 array(
 'frontend' =>
 array(
 'default' =>
 array(
 'backend' => 'Cm_Cache_Backend_Redis',
 'backend_options' =>
 array(
 'server' => '127.0.0.1',
 'port' => '6379'
 ),
 ),
 'page_cache' =>
 array(
 'backend' => 'Cm_Cache_Backend_Redis',
 'backend_options' =>
 array(
 'server' => '127.0.0.1',
 'port' => '6379',
 'database' => '1',
 'compress_data' => '0'
 )
 )
 )
 ),
http://devdocs.magento.com/guides/v2.0/config-guide/redis/redis-pg-cache.html
As far as I understand "page_cache" refers to Full Page Cache and I already have that in Varnish.
I checked many answers regarding Varnish, Redis and FPC in Magento 2 on this and other websites but still did not find the answer.
Question 1) Should I just remove that 'page_cache' part from the code? Or, does Varnish and Redis use different segments of FPC and I should keep it?
Question 2) Please share based on Your personal experience how well Varnish and Redis getting along in FPC in Magento 2 and would you reccomend to use both at the same time for Full Page Cache?
- 
 1This question deserves better answersladle3000– ladle30002019年04月01日 03:08:08 +00:00Commented Apr 1, 2019 at 3:08
- 
 what did you do? i am confused with same questions. can you please answer if you found any good solutions?Ashar Riaz– Ashar Riaz2019年09月17日 22:11:17 +00:00Commented Sep 17, 2019 at 22:11
2 Answers 2
I am using Varnish + Redis for Full Page Cache at the same time.
In Magento 2.3.2, after clear both cache, visit some pages, then you will find the database in Redis for page cache will not have any data.
So if you are using Varnish cache, Full Page Cache will not use the page_cache setting from env.php. If you remove Varnish, Full Page Cache will use the Redis again.
After my test, when I remove the page_cache part from the file env.php, there was no page load speed improvement, the load time is the same. So my answer is:
Question 1) Doesn't need to remove that 'page_cache' part from the code, there is no difference whether it is removed or not.
Question 2) In my personal experience, I removed the 'page_cache' part from the code, just for keeping the config codes clean in env.php.
Yes, you should just remove 'page_cache' part from the code.
In case you keep it, nothing so bad would happen.
In my own testing, both continue working and what's most important, both Redis and Varnish cache are still being invalidated once you're update your content.
No real benefit though.
Explore related questions
See similar questions with these tags.