Now that you are using the
default.vcl generated for you by Commerce, you can perform some final verifications to make sure that Varnish is working.
curl or another utility to view HTTP response headers when you visit any Commerce page in a web browser.
First, make sure you are using developer mode; otherwise, you will not 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:
If Varnish is working, any Commerce page with cacheable blocks should load in less than 150 ms. Examples of such pages are the front door and storefront category pages.
Use a browser inspector to measure page load times.
For example, to use the Chrome inspector:
Access any cacheable Commerce page in Chrome.
Right-click anywhere on the page.
From the pop-up menu, click Inspect Element
In the inspector pane, click the Network tab.
Refresh the page.
Scroll to the top of the inspector pane so you can see the URL of the page you are viewing.
The following figure shows an example of loading the
magento2 index page.
The page load time displays next to the page URL. In this case, the load time is 5 ms. This helps confirm that Varnish cached the page.
To view HTTP response headers, click the page URL (in the Name column).
You can view HTTP headers which are discussed in more detail in the Verify HTTP response headers section.
Make sure the
<magento_root>/var/page_cache directory is empty:
Log in to your Commerce server, or switch to, the file system owner.
Enter the following command:
rm -rf <magento_root>/var/page_cache/*
Access one or more cacheable Commerce pages.
If the directory is empty, congratulations! You successfully configured Varnish and Commerce to work together!
If you cleared the
var/page_cache/ directory, restart Varnish.
If you encounter 503 (Backend Fetch Failed) errors, see Troubleshooting 503 (Service Unavailable) errors in the Adobe Commerce Help Center.