Magento – Magento 2.3.4 + Varnish 6

magento2magento2.3varnish

I am having a problem with Magento open source 2.3.4 and its configuration to work with varnish 6. I have followed the devdocs about setting up varnish caching. I have verified that the varnish part works well with nginx and php-fpm by verifying that it works with a small demo page. The only part that is not working is Magento 2.3.4.

The nginx error log shows the following error:

2020/03/03 14:32:34 [error] 7273#7273: *4 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Zend_Cache_Exception: cache_dir "/usr/share/nginx/html/magento2/var/page_cache" is not writable in /usr/share/nginx/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php:209
Stack trace:
#0 /usr/share/nginx/html/magento2/vendor/magento/zendframework1/library/Zend/Cache/Backend/File.php(180): Zend_Cache::throwException('cache_dir "/usr...')
#1 /usr/share/nginx/html/magento2/vendor/colinmollenhour/cache-backend-file/File.php(87): Zend_Cache_Backend_File->setCacheDir('/usr/share/ngin...')
#2 /usr/share/nginx/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(153): Cm_Cache_Backend_File->__construct(Array)
#3 /usr/share/nginx/html/magento2/vendor/magento/zendframework1/library/Zend/Cache.php(94): Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)
#4 /usr/share/nginx/html/magento2/vendor/magento/framework/App/Cache/Frontend/Factory.php(156): Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...', Array, Array, true, tr" while reading response header from upstream, client: 127.0.0.1, server: www.example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.example.com"

It is clear that magento thinks it should be using its built in full page cache because it is trying to access var/page_cache. A correct installation using varnish would not be attempting to access this directory.

I have configured magento to use varnish. Does anybody have any insight as to why it is not working correctly?

Best Answer

you mistaken this functionality.

first of all you must have proper permissions set and access rights, no matter how cache is configured.

second you need to check your app/etc/env.php configuration file, it will tell you exactly where cache and session storage is.

then after you change settings you can manually flush caches to apply new settings

Related Topic