0

I just learned and implemented varnish reverse proxy to increase my website speed.

Everything works fine but something minor bothers me.

For some reason, when I check page TTFB for the first time, I get .999s, however, when I rerun the test the number drops to .237s.

I use the following website to check TTFB: https://www.webpagetest.org

and my website is: https://www.findfestival.com/

It makes me wonder if the first request to the website hits the cache. When I use curl I can see x-varnish but still it's strange that first time clicking on links are slower compared to the second time clicking on them. (specifically on mobile)

  • Can you please help me understand why first time Varnish cache doesn't hit?

This is my default.vcl is:

enter image description here

Thanks,

PS, I have seen this post and already tried the solution with no luck!

Varnish Cache first time hit

Community
  • 1
  • 1
shabk
  • 51
  • 1
  • 9

1 Answers1

0

Seeing how you have X-Mod-Pagespeed in your headers and minimalistic VCL, the conclusion is that you need to take a look at Downstream Caching and make sure that PageSpeed would not send Cache-Control: max-age=0, no-cache which breaks Varnish caching for the most part.

In my own experience, Pagespeed does not play well with Varnish even with downstream caching configuration applied.

It "loves" to send the aforementioned header no matter what. Even if you manage to turn this behaviour off, it results in PageSpeed's own assets not having proper Cache-Control headers plus a few more interesting issues like causing Varnish "hit-for-pass" when rebeaconing has to take place - which is really bad and breaks caching further.

Also have a look at possible configurations. You might want to put PageSpeed at your SSL terminator level (option #1) - that way you don't need Downstream Cache configuration and PageSpeed will be "in front" of Varnish.

Danila Vershinin
  • 8,725
  • 2
  • 29
  • 35
  • Thanks Daniel. The same thing was happening even before having pagespeed module on. I just installed pagespeed last night. I can turn it off so you see the same thing happens. – shabk Apr 02 '17 at 17:36
  • It makes sense to turn it off and also turn off CloudFlare (if that's what use use - seems so) for troubleshooting Varnish. – Danila Vershinin Apr 02 '17 at 18:48
  • I read your blog post and your past answer again. It totally makes sense to me. However, I'm not sure if I can fix the issue as it seems to be complex. Going to change the config to option #1 and see if that helps. Thanks again. :) – shabk Apr 03 '17 at 03:33