The current website running on Magento 2.2.4 CE and we have enabled varnish cache.
How do we know if varnish cache is working or not in Magento 2?
According to Magento, you can perform some final verifications to make sure Varnish is working.
One of which is Verifying HTTP response headers
First, make sure you are using Magento’s developer mode; otherwise, you won’t see the headers.
curl -I -v --location-trusted 'http://192.0.2.55/magento2'
X-Magento-Cache-Control: max-age=86400, public, s-maxage=86400 Age: 0 X-Magento-Cache-Debug: MISS
This value is also acceptable: X-Magento-Cache-Debug: HIT.
If you get a MISS value in that header, Varnish is (for some reason) unable or unwilling to cache your content.
You need to follow Magento 2 devdocs as they told step to step setting and configuration of varnish cache.
If you have already installed varnish cache on your server then you need to configure Port in admin of Developer section then you will require to final verification that it's working or not as per below guideline of Devdoc Magento 2:
Full configuration Guide:
As per Magento Docs,you can also check that Varnish cache working or not as per below steps:
Make sure the /var/page_cache directory is empty:
Step1: Log in to your Magento server, or switch to, the Magento file system owner.
Step2: Clear page_cache manually with below command
rm -rf <your Magento install dir>/var/page_cache/*
Step3: Access one or more cacheable Magento pages by navigate some page randomly.
Step4: Check the var/page_cache/ directory.
If the directory is empty, congratulations! You successfully configured Varnish and Magento to work together! If you cleared the var/page_cache/ directory, restart Varnish.