The X-Magento-Cache-Debug
header is set by Varnish VCL itself. From a standard VCL:
sub vcl_deliver {
if (resp.http.X-Magento-Debug) {
if (resp.http.x-varnish ~ " ") {
set resp.http.X-Magento-Cache-Debug = "HIT";
set resp.http.Grace = req.http.grace;
} else {
set resp.http.X-Magento-Cache-Debug = "MISS";
}
} else {
unset resp.http.Age;
}
# ....
unset resp.http.X-Magento-Debug;
# ...
}
So its inclusion is dictated by presence of the header X-Magento-Debug
which is set by Magento code here:
if ($this->state->getMode() == AppState::MODE_DEVELOPER) {
$result->setHeader('X-Magento-Debug', 1);
}
As you can decipher from the code above, Magento 2 sets theX-Magento-Debug
header for Varnish when it's being run in developer mode.
"For Varnish" - taking note that few lines later (in VCL), the X-Magento-Debug
is being unset and clients will only see the X-Magento-Cache-Debug
header.
Subsequently, make sure that you're not dealing with the note from your own post:
Environment variables may override this value
Make sure that:
- NGINX/Apache is setting production mode via an environment variable (as opposed to developer or default), e.g.:
set $MAGE_MODE production;
(NGINX)
- You are using the standard VCL code
- You have cleared PHP OPcache - potentially, you are running with
validate_timestamps = Off
, and the PHP-FPM pool is still running in developer mode until the cache is pruned.