0

Hi dears I installed varnish cache on centos 7 , nginx 1.20.1 and magento 2.4.5 -p1.

After that I don't seeing any header about varnish on my browser.

Another thing when I clear cache I have log in varnishlog.

Just I have x-magento-debug :1 did I installed successfully ?

I tested it in developer mode

    *   << Request  >> 65563
-   Begin          req 65560 rxreq
-   Timestamp      Start: 1669538667.505033 0.000000 0.000000
-   Timestamp      Req: 1669538667.505033 0.000000 0.000000
-   VCL_use        boot
-   ReqStart       217.218.39.33 56922 a0
-   ReqMethod      GET
-   ReqURL         /
-   ReqProtocol    HTTP/1.1
-   ReqHeader      Host: oursite
-   ReqHeader      Connection: keep-alive
-   ReqHeader      Cache-Control: max-age=0
-   ReqHeader      Upgrade-Insecure-Requests: 1
-   ReqHeader      User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
-   ReqHeader      Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
-   ReqHeader      Accept-Encoding: gzip, deflate
-   ReqHeader      Accept-Language: en-US,en;q=0.9,fa;q=0.8,de;q=0.7
-   ReqHeader      Cookie: _ga=GA1.2.402651066.1669532827; _gid=GA1.2.913114647.1669532827; AMCVS_8F99160E571FC0427F000101%40AdobeOrg=1; AMCV_8F99160E571FC0427F000101%40AdobeOrg=-1124106680%7CMCIDTS%7C19324%7CMCMID%7C21125325410411075930590493714775457981%7CMCAAMLH-1670138
-   ReqHeader      X-Forwarded-For: 217.218.39.33
-   VCL_call       RECV
-   ReqUnset       Host: oursite
-   ReqHeader      Host: oursite
-   ReqURL         /
-   VCL_return     hash
-   ReqUnset       Accept-Encoding: gzip, deflate
-   ReqHeader      Accept-Encoding: gzip
-   VCL_call       HASH
-   VCL_return     lookup
-   HitMiss        65556 51.242489
-   VCL_call       MISS
-   VCL_return     fetch
-   Link           bereq 65564 fetch
-   Timestamp      Fetch: 1669538668.060497 0.555464 0.555464
-   RespProtocol   HTTP/1.1
-   RespStatus     200
-   RespReason     OK
-   RespHeader     Server: nginx/1.20.1
-   RespHeader     Date: Sun, 27 Nov 2022 08:44:28 GMT
-   RespHeader     Content-Type: text/html; charset=UTF-8
-   RespHeader     X-Powered-By: PHP/7.4.33
-   RespHeader     Set-Cookie: mage-cache-sessid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; secure; SameSite=None
-   RespHeader     Set-Cookie: PHPSESSID=eceligmlkvgt7k80ngqj4gior2; expires=Sun, 27-Nov-2022 09:44:27 GMT; Max-Age=3600; path=/; domain=oursite; HttpOnly; SameSite=Lax
-   RespHeader     Pragma: no-cache
-   RespHeader     Cache-Control: max-age=0, must-revalidate, no-cache, no-store
-   RespHeader     Expires: Sat, 27 Nov 2021 08:44:27 GMT
-   RespHeader     X-Magento-Debug: 1
-   RespHeader     Content-Security-Policy-Report-Only: font-src *.fontawesome.com data: 'self' 'unsafe-inline'; form-action 'self' 'unsafe-inline'; frame-ancestors 'self'; frame-src fast.amc.demdex.net *.adobe.com bid.g.doubleclick.net *.youtube.com *.youtube-nocookie.com
-   RespHeader     X-Content-Type-Options: nosniff
-   RespHeader     X-XSS-Protection: 1; mode=block
-   RespHeader     X-Frame-Options: SAMEORIGIN
-   RespHeader     Vary: Accept-Encoding
-   RespHeader     X-Magento-Cache-Control: max-age=0, must-revalidate, no-cache, no-store
-   RespHeader     Content-Encoding: gzip
-   RespHeader     X-Varnish: 65563
-   RespHeader     Age: 0
-   RespHeader     Via: 1.1 varnish (Varnish/6.6)
-   VCL_call       DELIVER
-   RespHeader     X-Magento-Cache-Debug: UNCACHEABLE
-   RespUnset      Pragma: no-cache
-   RespHeader     Pragma: no-cache
-   RespUnset      Expires: Sat, 27 Nov 2021 08:44:27 GMT
-   RespHeader     Expires: -1
-   RespUnset      Cache-Control: max-age=0, must-revalidate, no-cache, no-store
-   RespHeader     Cache-Control: no-store, no-cache, must-revalidate, max-age=0
-   RespUnset      X-Magento-Debug: 1
-   RespUnset      X-Powered-By: PHP/7.4.33
-   RespUnset      Server: nginx/1.20.1
-   RespUnset      X-Varnish: 65563
-   RespUnset      Via: 1.1 varnish (Varnish/6.6)
-   VCL_return     deliver
-   Timestamp      Process: 1669538668.060581 0.555548 0.000084
-   Filters
-   RespHeader     Accept-Ranges: bytes
-   RespHeader     Content-Length: 28145
-   RespHeader     Connection: keep-alive
-   Timestamp      Resp: 1669538668.061301 0.556268 0.000720
-   ReqAcct        1419 0 1419 2420 28145 30565
-   End
**  << BeReq    >> 65564
--  Begin          bereq 65563 fetch
--  VCL_use        boot
--  Timestamp      Start: 1669538667.505333 0.000000 0.000000
--  BereqMethod    GET
--  BereqURL       /
--  BereqProtocol  HTTP/1.1
--  BereqHeader    Upgrade-Insecure-Requests: 1
--  BereqHeader    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
--  BereqHeader    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
--  BereqHeader    Accept-Language: en-US,en;q=0.9,fa;q=0.8,de;q=0.7
--  BereqHeader    Cookie: _ga=GA1.2.402651066.1669532827; _gid=GA1.2.913114647.1669532827; AMCVS_8F99160E571FC0427F000101%40AdobeOrg=1; AMCV_8F99160E571FC0427F000101%40AdobeOrg=-1124106680%7CMCIDTS%7C19324%7CMCMID%7C21125325410411075930590493714775457981%7CMCAAMLH-1670138
--  BereqHeader    X-Forwarded-For: 217.218.39.33
--  BereqHeader    Host: oursite
--  BereqHeader    Accept-Encoding: gzip
--  BereqHeader    X-Varnish: 65564
--  VCL_call       BACKEND_FETCH
--  VCL_return     fetch
--  Timestamp      Fetch: 1669538667.505422 0.000089 0.000089
--  Timestamp      Connected: 1669538667.505432 0.000099 0.000010
--  BackendOpen    34 default 127.0.0.1 8080 127.0.0.1 38448 reuse
--  Timestamp      Bereq: 1669538667.505585 0.000251 0.000152
--  Timestamp      Beresp: 1669538668.046902 0.541568 0.541317
--  BerespProtocol HTTP/1.1
--  BerespStatus   200
--  BerespReason   OK
--  BerespHeader   Server: nginx/1.20.1
--  BerespHeader   Date: Sun, 27 Nov 2022 08:44:28 GMT
--  BerespHeader   Content-Type: text/html; charset=UTF-8
--  BerespHeader   Transfer-Encoding: chunked
--  BerespHeader   Connection: keep-alive
--  BerespHeader   X-Powered-By: PHP/7.4.33
--  BerespHeader   Set-Cookie: mage-cache-sessid=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; secure; SameSite=None
--  BerespHeader   Set-Cookie: PHPSESSID=eceligmlkvgt7k80ngqj4gior2; expires=Sun, 27-Nov-2022 09:44:27 GMT; Max-Age=3600; path=/; domain=oursite; HttpOnly; SameSite=Lax
--  BerespHeader   Pragma: no-cache
--  BerespHeader   Cache-Control: max-age=0, must-revalidate, no-cache, no-store
--  BerespHeader   Expires: Sat, 27 Nov 2021 08:44:27 GMT
--  BerespHeader   X-Magento-Debug: 1
--  BerespHeader   Content-Security-Policy-Report-Only: font-src *.fontawesome.com data: 'self' 'unsafe-inline'; form-action 'self' 'unsafe-inline'; frame-ancestors 'self'; frame-src fast.amc.demdex.net *.adobe.com bid.g.doubleclick.net *.youtube.com *.youtube-nocookie.com
--  BerespHeader   X-Content-Type-Options: nosniff
--  BerespHeader   X-XSS-Protection: 1; mode=block
--  BerespHeader   X-Frame-Options: SAMEORIGIN
--  BerespHeader   Content-Encoding: gzip
--  BerespHeader   Vary: Accept-Encoding
--  TTL            RFC 0 10 0 1669538668 1669538668 1669538668 1638002667 0 cacheable
--  VCL_call       BACKEND_RESPONSE
--  TTL            VCL 0 259200 0 1669538668 cacheable
--  BerespHeader   X-Magento-Cache-Control: max-age=0, must-revalidate, no-cache, no-store
--  TTL            VCL 120 259200 0 1669538668 cacheable
--  TTL            VCL 120 259200 0 1669538668 uncacheable
--  VCL_return     deliver
--  Timestamp      Process: 1669538668.046969 0.541635 0.000066
--  Filters         gunzip esi_gzip
--  BerespUnset    Content-Encoding: gzip
--  BerespHeader   Content-Encoding: gzip
--  Storage        malloc Transient
--  Fetch_Body     2 chunked -
--  Gzip           G F E 190843 28145 80 225080 225090
--  Gzip           U F - 28120 190843 80 224880 224890
--  BackendClose   34 default recycle
--  Timestamp      BerespBody: 1669538668.060481 0.555148 0.013512
--  Length         28145
--  BereqAcct      1410 0 1410 2381 28120 30501
--  End
1
  • please help me!
    – Peren
    Commented Nov 27, 2022 at 8:49

1 Answer 1

0

First, did you start the varnish service:

service varnish start

If Varnish fails to start as a service, start it from the command line as follows:

Start the Varnish CLI:

varnishd -d -f /etc/varnish/default.vcl

Start the Varnish child process:

When prompted, enter start

The following messages display to confirm a successful start:

child (29805) Started 200 0

Child (29805) said Child (29805) said Child starts

To Verify HTTP Header Response

There are several ways to look at response headers, including using a browser plug-in or a browser inspector.

The following example uses curl. You can enter this command from any machine that can access the Magento server using HTTP.

curl -I -v --location-trusted '<your Magento base URL>'

For example,

curl -I -v --location-trusted 'http://192.0.2.55/magento2'

Look for headers like the following:

Content-Type: text/html; charset=iso-8859-1 X-Varnish: 15 Age: 0 Via: 1.1 varnish-v6 X-Magento-Cache-Debug: HIT

Thanks

3
  • Hi thanks for your answer varnish started and i haven't error on log but when i get curl show below : < HTTP/1.1 503 Backend fetch failed HTTP/1.1 503 Backend fetch failed < Retry-After: 5 Retry-After: 5 < X-Magento-Cache-Debug: MISS X-Magento-Cache-Debug: MISS < 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 < Connection: keep-alive Connection: keep-alive
    – Peren
    Commented Nov 26, 2022 at 7:31
  • and my backend works well
    – Peren
    Commented Nov 26, 2022 at 7:55
  • Error: Varnishd is already running (pid=5918) (pidfile=/var/lib/varnish/localhost//_.pid)
    – Peren
    Commented Nov 26, 2022 at 7:56

Your Answer

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

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