I am quite new to varnish however I have configured varnish in my Dev environment and seems to be going well.

The cache however doesn't seem to flush with Magento. Subsequent requests however remain lightening quick with the old content until refreshing the page on a client PC which them seems to reload the page properly and update the cached page.

I have run the below command to update the cache host:

bin/magento setup:config:set --http-cache-hosts=localhost:80

I was unsure about the port whether 6082 or 80 but checking for purge requests with below command shows results when running a cache refresh:

varnishlog -g request -q 'ReqMethod eq "PURGE"


*   << Request  >> 98314
-   Begin          req 98313 rxreq
-   Timestamp      Start: 1511438530.550488 0.000000 0.000000
-   Timestamp      Req: 1511438530.550488 0.000000 0.000000
-   ReqStart       ::1 41502
-   ReqMethod      PURGE
-   ReqURL         /
-   ReqProtocol    HTTP/1.1
-   ReqHeader      X-Magento-Tags-Pattern: .*
-   ReqHeader      Host: localhost
-   ReqHeader      X-Forwarded-For: ::1
-   VCL_call       RECV
-   VCL_acl        MATCH purge "localhost"
-   VCL_return     synth
-   VCL_call       HASH
-   VCL_return     lookup
-   Timestamp      Process: 1511438530.550571 0.000083 0.000083
-   RespHeader     Date: Thu, 23 Nov 2017 12:02:10 GMT
-   RespHeader     Server: Varnish
-   RespHeader     X-Varnish: 98314
-   RespProtocol   HTTP/1.1
-   RespStatus     200
-   RespReason     OK
-   RespReason     Purged
-   VCL_call       SYNTH
-   RespHeader     Content-Type: text/html; charset=utf-8
-   RespHeader     Retry-After: 5
-   VCL_return     deliver
-   RespHeader     Content-Length: 226
-   Storage        malloc Transient
-   RespHeader     Accept-Ranges: bytes
-   Debug          "RES_MODE 2"
-   RespHeader     Connection: keep-alive
-   Timestamp      Resp: 1511438530.550634 0.000145 0.000062
-   ReqAcct        65 0 65 218 226 444
-   End

I have tried restarting varnish however the cache remains. This is becoming an issue when testing deploying new static content as some resources become unavailable having old urls stored in the cache.

Doing this:

curl -I -v --location-trusted 'http://dev.magento2.com'

Does return a MISS once cache cleared / flushed in magento. This was run from the web server. Second request will then return HIT as cache has been rebuilt. Just my client PC seems to behave like a hit until i click refresh.

Why do i still need to refresh the page on my client PC in order for the content to update?

  • Your issues sound like they have nothing to with varnish but your browser cache. Check your expire and caching headers with browser dev tools or curl -I – Jonas Hünig Nov 23 '17 at 12:44
  • Its just this never really happened until varnish. I can see that this is probably cached in browser but how would i force browser caches to flush the page? I thought browser caches only stored stuff like resources and that signing static files bascially sorts this? – harri Nov 23 '17 at 13:32
  • Also i notice the issues are present across different borwsers. Magento2.com/product1 is messed up on both my firefox and chrome. Refreshing the page on either will fix on both. – harri Nov 23 '17 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.