Magento – FPC Cache Verification

cachefull-page-cachemagento2

I'm currently trying to validate if FPC is working properly, however I'm getting results I don't fully understand.

If I'm in developer mode and have a clear cache I can see the following headers:

X-Magento-Cache-Debug:MISS
X-Magento-Cache-Control:max-age=86400, public, s-maxage=86400

On a pagereload I get a:

X-Magento-Cache-Debug:HIT

So this leads to the assumption that everything is working out fine. However the actual Cache-Control Header is always set to be:

Cache-Control:max-age=0, must-revalidate, no-cache, no-store

I thought that might just be because of developer mode, so I changed to deployment mode and expected the Cache-Control header to be:

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

But as mentioned before I just got:

Cache-Control:max-age=0, must-revalidate, no-cache, no-store

Shouldn't the X-Magento-Cache-Control relate to the actual Cache-Control value? I currently not sure how the Magento FPC should Work but I'm assuming that this isn't the correct behavior and would not work if I will switch the FPC to use varnish. Any input on what is causing this issue will be appreciated.

Best Answer

From my understanding the cache-control response header is only important for assets, that should be cached in the browser cache - meaning it's an instruction for the browser, to cache this file locally.

Since the document itself is not cached client side (but server side), the cache control header should be ok this way.

As confirmed by this blog post, you should be doing fine, since the debug headers from magento should show the actual values for the server side cachíng mechanism (https://xumulus.com/make-sure-magento-2-full-page-cache-will-working-order-site/)

  • Place store in Developer Mode
  • Inspect the page headers in your browsers debug network tab.
  • Look forX-Magento-Cache-Debug: MISS
  • Refresh the page, it should change to HIT
Related Topic