0

I have installed Varnish and configured it as per as the guideline. And when I try it curl -I https://d-o-m-a-i-n.com I get following which seems its working correctly.

HTTP/1.1 200 OK
Date: Sat, 28 Mar 2020 03:17:02 GMT
Server: Apache/2.4.18 (Ubuntu)
Expires: Sun, 29 Mar 2020 03:17:03 GMT
Cache-Control: max-age=86400, public, s-maxage=86400
Pragma: cache
X-Magento-Tags: cms_b_porto_homeslider_3,store,cms_b,cms_p_91,cms_b_porto_custom_notice_new,cat_p,cat_c_p_30,cat_p_22,cat_p_1,cat_p_34,cat_p_21,cat_p_41,cat_p_11,cat_p_39,cat_p_35,cat_p_33,cms_b_porto_footer_top_1_for_5,cms_b_porto_footer_middle_1_for_5,cms_b_porto_footer_middle_2_for_5
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
X-UA-Compatible: IE=edge
Content-Type: text/html; charset=UTF-8
X-Varnish: 33268 3
Age: 13957
Via: 1.1 varnish (Varnish/5.2)
X-Cache: cached
Accept-Ranges: bytes

But when I check in Google Chrome header response I get followings where it shows Varnish is not caching and age is 0?

Accept-Ranges: bytes
Age: 0
Cache-Control: max-age=86400, public, s-maxage=86400
Connection: Keep-Alive
Content-Encoding: gzip
Content-Length: 20027
Content-Type: text/html; charset=UTF-8
Date: Sat, 28 Mar 2020 07:13:35 GMT
Expires: Sun, 29 Mar 2020 07:13:35 GMT
Keep-Alive: timeout=5, max=100
Pragma: cache
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Via: 1.1 varnish (Varnish/5.2)
X-Cache: uncached
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Magento-Tags: cms_b_porto_homeslider_3,store,cms_b,cms_p_91,cms_b_porto_custom_notice_new,cat_p,cat_c_p_30,cat_p_1,cat_p_22,cat_p_21,cat_p_11,cat_p_34,cat_p_41,cat_p_39,cat_p_35,cat_p_33,cms_b_porto_footer_top_1_for_5,cms_b_porto_footer_middle_1_for_5,cms_b_porto_footer_middle_2_for_5
X-UA-Compatible: IE=edge
X-Varnish: 1704417
X-XSS-Protection: 1; mode=block

Do you have any ideas why that is?

This is what it shows from varnishstat

```MGT.child_start                                                                                                                            1          0.00           .            0.00          0.00          0.00
MAIN.summs                                                                                                                             32398          0.00           .            0.00          0.00          0.00
MAIN.uptime                                                                                                                       0+13:18:05
MAIN.sess_conn                                                                                                                          1208          0.00           .            0.00          0.00          0.00
MAIN.client_req_400                                                                                                                        1          0.00           .            0.00          0.00          0.00
MAIN.client_req                                                                                                                         9089          0.00           .            0.00          0.00          0.00
MAIN.cache_hit                                                                                                                          2834          0.00           .            0.00          0.00          0.00
MAIN.cache_miss                                                                                                                          236          0.00           .            0.00          0.00          0.00
MAIN.backend_conn                                                                                                                        622          0.00           .            0.00          0.00          0.00
MAIN.backend_reuse                                                                                                                      6520          0.00           .            0.00          0.00          0.00
MAIN.backend_recycle                                                                                                                    7042          0.00           .            0.00          0.00          0.00
MAIN.backend_retry                                                                                                                         2          0.00           .            0.00          0.00          0.00
MAIN.fetch_length                                                                                                                       6033          0.00           .            0.00          0.00          0.00
MAIN.fetch_chunked                                                                                                                       106          0.00           .            0.00          0.00          0.00
MAIN.fetch_none                                                                                                                          820          0.00           .            0.00          0.00          0.00
MAIN.fetch_304                                                                                                                           161          0.00           .            0.00          0.00          0.00
MAIN.fetch_failed                                                                                                                          2          0.00           .            0.00          0.00          0.00
MAIN.pools                                                                                                                                 2          0.00           .            2.00          2.00          2.00
MAIN.threads                                                                                                                             200          0.00           .          200.00        200.00        200.00
MAIN.threads_created                                                                                                                     200          0.00           .            0.00          0.00          0.00
MAIN.busy_sleep                                                                                                                           20          0.00           .            0.00          0.00          0.00
MAIN.busy_wakeup                                                                                                                          20          0.00           .            0.00          0.00          0.00
MAIN.n_object                                                                                                                            236          0.00           .          236.00        236.00        236.00
MAIN.n_objectcore                                                                                                                        315          0.00           .          315.00        315.00        315.00
MAIN.n_objecthead                                                                                                                        282          0.00           .          282.00        282.00        282.00varnishlog is taking ages to get me log. But here is the varshstats shows its hitting
```MGT.child_start                                                                                                                            1          0.00           .            0.00          0.00          0.00
MAIN.summs                                                                                                                             32398          0.00           .            0.00          0.00          0.00
MAIN.uptime                                                                                                                       0+13:18:05
MAIN.sess_conn                                                                                                                          1208          0.00           .            0.00          0.00          0.00
MAIN.client_req_400                                                                                                                        1          0.00           .            0.00          0.00          0.00
MAIN.client_req                                                                                                                         9089          0.00           .            0.00          0.00          0.00
MAIN.cache_hit                                                                                                                          2834          0.00           .            0.00          0.00          0.00
MAIN.cache_miss                                                                                                                          236          0.00           .            0.00          0.00          0.00
MAIN.backend_conn                                                                                                                        622          0.00           .            0.00          0.00          0.00
MAIN.backend_reuse                                                                                                                      6520          0.00           .            0.00          0.00          0.00
MAIN.backend_recycle                                                                                                                    7042          0.00           .            0.00          0.00          0.00
MAIN.backend_retry                                                                                                                         2          0.00           .            0.00          0.00          0.00
MAIN.fetch_length                                                                                                                       6033          0.00           .            0.00          0.00          0.00
MAIN.fetch_chunked                                                                                                                       106          0.00           .            0.00          0.00          0.00
MAIN.fetch_none                                                                                                                          820          0.00           .            0.00          0.00          0.00
MAIN.fetch_304                                                                                                                           161          0.00           .            0.00          0.00          0.00
MAIN.fetch_failed                                                                                                                          2          0.00           .            0.00          0.00          0.00
MAIN.pools                                                                                                                                 2          0.00           .            2.00          2.00          2.00
MAIN.threads                                                                                                                             200          0.00           .          200.00        200.00        200.00
MAIN.threads_created                                                                                                                     200          0.00           .            0.00          0.00          0.00
MAIN.busy_sleep                                                                                                                           20          0.00           .            0.00          0.00          0.00
MAIN.busy_wakeup                                                                                                                          20          0.00           .            0.00          0.00          0.00
MAIN.n_object                                                                                                                            236          0.00           .          236.00        236.00        236.00
MAIN.n_objectcore                                                                                                                        315          0.00           .          315.00        315.00        315.00
MAIN.n_objecthead                                                                                                                        282          0.00           .          282.00        282.00        282.00

Here is output

**  << BeReq    >> 853523
--  Begin          bereq 853522 fetch
--  Timestamp      Start: 1585658838.119791 0.000000 0.000000
--  BereqMethod    GET
--  BereqURL       /
--  BereqProtocol  HTTP/1.1
--  BereqHeader    User-Agent: AWS Security Scanner
--  BereqHeader    Accept: */*
--  BereqHeader    Host: 169.254.169.254
--  BereqHeader    X-Forwarded-For: 44.224.22.196
--  BereqHeader    Accept-Encoding: gzip
--  BereqHeader    X-Varnish: 853523
--  VCL_call       BACKEND_FETCH
--  VCL_return     fetch
--  BackendOpen    26 boot.default 127.0.0.1 8080 127.0.0.1 48790
--  BackendStart   127.0.0.1 8080
--  Timestamp      Bereq: 1585658838.119860 0.000069 0.000069
--  Timestamp      Beresp: 1585658838.159034 0.039243 0.039174
--  BerespProtocol HTTP/1.1
--  BerespStatus   302
--  BerespReason   Found
--  BerespHeader   Date: Tue, 31 Mar 2020 12:47:18 GMT
--  BerespHeader   Server: Apache/2.4.18 (Ubuntu)
--  BerespHeader   Set-Cookie: PHPSESSID=mkjr1bsl2p61gf9gb8vluidq85; expires=Tue, 31-Mar-2020 22:47:18 GMT; Max-Age=36000; path=/; domain=169.254.169.254; HttpOnly
--  BerespHeader   Expires: Sun, 31 Mar 2019 12:47:18 GMT
--  BerespHeader   Cache-Control: max-age=0, must-revalidate, no-cache, no-store
--  BerespHeader   Pragma: no-cache
--  BerespHeader   Location: http://domain.com/?SID=mkjr1bsl2p61gf9gb8vluidq85
--  BerespHeader   X-Content-Type-Options: nosniff
--  BerespHeader   X-XSS-Protection: 1; mode=block
--  BerespHeader   X-Frame-Options: SAMEORIGIN
--  BerespHeader   X-UA-Compatible: IE=edge
--  BerespHeader   Content-Length: 0
--  BerespHeader   Content-Type: text/html; charset=UTF-8
--  TTL            RFC 0 10 0 1585658838 1585658838 1585658838 1554036438 0
--  VCL_call       BACKEND_RESPONSE
--  TTL            VCL 0 259200 0 1585658838
--  TTL            VCL 0 259200 0 1585658838
--  VCL_return     deliver
--  Storage        malloc Transient
--  ObjProtocol    HTTP/1.1
--  ObjStatus      302
--  ObjReason      Found
--  ObjHeader      Date: Tue, 31 Mar 2020 12:47:18 GMT
--  ObjHeader      Server: Apache/2.4.18 (Ubuntu)
--  ObjHeader      Set-Cookie: PHPSESSID=mkjr1bsl2p61gf9gb8vluidq85; expires=Tue, 31-Mar-2020 22:47:18 GMT; Max-Age=36000; path=/; domain=169.254.169.254; HttpOnly
--  ObjHeader      Expires: Sun, 31 Mar 2019 12:47:18 GMT
--  ObjHeader      Cache-Control: max-age=0, must-revalidate, no-cache, no-store
--  ObjHeader      Pragma: no-cache
--  ObjHeader      Location: http://domain.com/?SID=mkjr1bsl2p61gf9gb8vluidq85
--  ObjHeader      X-Content-Type-Options: nosniff
--  ObjHeader      X-XSS-Protection: 1; mode=block
--  ObjHeader      X-Frame-Options: SAMEORIGIN
--  ObjHeader      X-UA-Compatible: IE=edge
--  ObjHeader      Content-Length: 0
--  ObjHeader      Content-Type: text/html; charset=UTF-8
--  Fetch_Body     0 none -
--  BackendReuse   26 boot.default
--  Timestamp      BerespBody: 1585658838.159114 0.039323 0.000080
--  Length         0
--  BereqAcct      162 0 162 606 0 606
--  End

1 Answer 1

0

I'd love to see the varnishlog output for request. There are so many reasons why Chrome doesn't cache. The main one I can think of is the fact that Chrome might send cookies and by default cUrl doesn't.

Have a look at https://feryn.eu/blog/varnishlog-measure-varnish-cache-performance/. It's a blog post I wrote about using varnishlog to figure out what's going on and why certain pages don't get served from cache.

Maybe try the following command, assuming the issue occurs on the homepage:

varnishlog -g request -Q "ReqUrl eq '/'"

The varnishlog output will provide the necessary answers.

4
  • varnishlog is taking ages to get me log. But here is the varshstats shows its hitting Please check varnish stats and let me know if you can get anything from it Mar 28, 2020 at 16:35
  • varnishstat doesn't help me, unfortunately. I need detailed logs about transactions that are happening, not the general statistics. The stats show what is happening, the logs show why it is happening. The reason why varnishlog might take a lot of time to run is because you may not have the permissions with your current user. Please try running sudo varnishlog -g request -Q "ReqUrl eq '/'" Mar 30, 2020 at 8:16
  • Updated in question can you please check Mar 31, 2020 at 13:42
  • Unfortunately you only sent the "backend" part. Please include the full varnishlog output, including the client request part. But since there's a backend request/response part, it means Varnish isn't serving it from cache. Very curious to see the client request part where the decisions are made. Mar 31, 2020 at 18:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.