TransWikia.com

Magento2 need to check if varnish cache is applied or not

Magento Asked on November 25, 2021

How can I verify whether my Varnish Cache is properly configured or not.

Here are the things that appeared

  1. page_cache is not getting regenerated
  2. Site speed as per Google page speed is improved

My site is set on http://x.x.x.x & is redirected to https://x.x.xx.x

HTTP/1.1 200 OK
< Date: Wed, 22 Jul 2020 13:59:25 GMT
Date: Wed, 22 Jul 2020 13:59:25 GMT
< Server: Apache
Server: Apache
< Pragma: cache
Pragma: cache
< Cache-Control: max-age=86400, public, s-maxage=86400
Cache-Control: max-age=86400, public, s-maxage=86400
< Expires: Thu, 23 Jul 2020 13:59:26 GMT
Expires: Thu, 23 Jul 2020 13:59:26 GMT
< X-Magento-Tags: store,cms_b,cat_c,cat_c_38,cat_c_20,cat_c_41,cat_c_3,cat_c_58,cat_c_39,cms_b_,cms_b_31,cms_b_em0144-fashion-area-footer-inner-payment,cms_b_60,cms_b_em0144-jewelry-area-footer01-information-footer07,cms_b_48,cms_b_em0144-jewerly-main-slideshow,cms_b_52,cms_b_em0144-jewelry-top-banners,cms_b_54,cms_b_em0144-jewelry-area-main01-new-arrivals-grid12,cms_p_7
X-Magento-Tags: store,cms_b,cat_c,cat_c_38,cat_c_20,cat_c_41,cat_c_3,cat_c_58,cat_c_39,cms_b_,cms_b_31,cms_b_em0144-fashion-area-footer-inner-payment,cms_b_60,cms_b_em0144-jewelry-area-footer01-information-footer07,cms_b_48,cms_b_em0144-jewerly-main-slideshow,cms_b_52,cms_b_em0144-jewelry-top-banners,cms_b_54,cms_b_em0144-jewelry-area-main01-new-arrivals-grid12,cms_p_7
< X-Content-Type-Options: nosniff
X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
X-Frame-Options: SAMEORIGIN
< Set-Cookie: PHPSESSID=3fe21bcb4a2d0cd17f4304ff6c6346ca; expires=Wed, 22-Jul-2020 14:59:26 GMT; Max-Age=3600; path=/; domain=monogramshop.com.au; secure; HttpOnly
Set-Cookie: PHPSESSID=3fe21bcb4a2d0cd17f4304ff6c6346ca; expires=Wed, 22-Jul-2020 14:59:26 GMT; Max-Age=3600; path=/; domain=monogramshop.com.au; secure; HttpOnly
< Content-Length: 101554
Content-Length: 101554
< Vary: User-Agent
Vary: User-Agent
< Connection: keep-alive
Connection: keep-alive
< X-UA-Compatible: IE=edge
X-UA-Compatible: IE=edge
< Cache-Control: max-age=86400, private, must-revalidate
Cache-Control: max-age=86400, private, must-revalidate
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8

The above is output of curl -I -v –location-trusted ‘https://x.x.x/’

< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Wed, 22 Jul 2020 14:02:19 GMT
Date: Wed, 22 Jul 2020 14:02:19 GMT
< Last-Modified: Mon, 07 Oct 2019 08:45:22 GMT
Last-Modified: Mon, 07 Oct 2019 08:45:22 GMT
< Accept-Ranges: bytes
Accept-Ranges: bytes
< Content-Type: text/html
Content-Type: text/html
< Content-Encoding: gzip
Content-Encoding: gzip
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Pragma: no-cache
Pragma: no-cache
< Expires: -1
Expires: -1
< Cache-Control: no-store, no-cache, must-revalidate, max-age=0
Cache-Control: no-store, no-cache, must-revalidate, max-age=0
< Via: HTTP/1.1 forward.http.proxy:3128
Via: HTTP/1.1 forward.http.proxy:3128
< Connection: keep-alive
Connection: keep-alive

The above is output of curl -I -v –location-trusted ‘http://x.x.x/’

One Answer

Magento's VCL file will strip off the X-Varnish header, which indicates whether or not Varnish is used.

By removing unset resp.http.X-Varnish; from the sub vcl_deliver subroutine, the header will reapper.

If your HTTP response then contains an X-Varnish response header, you know it was served through Varnish.

Enabling Magento's debug mode will also add some extra debug headers to your HTTP responses, which will help you understand whether or not the response was a cache hit or a cache miss.

Answered by Thijs Feryn on November 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP