I had Varnish caching working for many months (staging environment), but just before launch I realised it is no longer caching any page.

- My thoughts -

I've generated a PHP file with randomised output. Unlike Magento pages, Varnish seems to cache this page just fine. Therefore I'm thinking this has something to do with the headers being set by Magento.

- Magento headers -

I have disabled Varnish for now, to look into the original headers being set by Magento. Below is a screenshot of the headers on a basic product page. I have no idea where to start looking. What could be causing Varnish not to cache the page?

enter image description here

  • I've read something about Varnish not caching a page where cookies are being set. Seems like Magento is setting three different cookies on this page. Can this be the cause? How do I disable those cookies?
  • Cache-Control mentions no-cache, no-store. Would be fine if those were Varnish headers to the client, but Magento passing this to Varnish instead doesn't look good to me?

I'm unsure what to do, because I know Varnish caching on Magento pages worked just fine before. I have no idea when exactly things stopped working, so I'm having a hard time tracking down the the cause of the issue.


  • Apache
  • Nginx (SSL reverse proxy)
  • Varnish
  • Double check Varnish FPC is still configured correctly and enabled in Magento. Are you sure that the Nginx proxy is passing requests to Varnish and not to Magento directly?
    – paj
    Commented Mar 16, 2021 at 10:51
  • @paj: Yes I have. All was configured just fine, but a module I installed was causing Magento to set the wrong headers on the full website. I should've checked this earlier. Full context posted as an answer. Thanks for your comment though!
    – Jason
    Commented Mar 16, 2021 at 11:11
  • OK, good news! Was your site in production mode? It was strange that there were no Varnish debug headers showing at all.
    – paj
    Commented Mar 16, 2021 at 11:13
  • Ah, I think you misunderstood. The headers I provided were headers set by Magento itself before reaching Varnish. That's why there's no Varnish debug headers.
    – Jason
    Commented Mar 16, 2021 at 11:29

1 Answer 1


I found the cause of the problem, and I should be ashamed.


The docs clearly state:

Using cacheable="false" inside the default.xml file disables caching for all pages on the site.

The only module I had added in the past months was a module to hide VAT-information from the checkout process (https://github.com/dsasmita/magento2-hide-tax). I assumed this module couldn't be the issue because it's only related to the checkout process, but I should've checked just to be sure. Apparently it contains a default.xml file with cacheable="false" inside it. Shame on me, haha.

I'm not yet sure if removing this will cause new trouble. But I removed it for now, and the Cache-Control headers instantly change to:

Cache-Control: max-age=86400, public, s-maxage=86400

Enabled Varnish and Nginx again, and caching is working just perfect again.

Lesson learnt: trust the docs, not your gut feeling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.