My app is structured in a way that when you access www.example.com you are redirected to www.example.com/home. So, that means I have nothing on the main domain only a file redirecting the user to /home.
What I realize is that Varnish is caching www.example.com/home so when I access www.example.com it's not serving me the cached page. I run a stress test on Blitz using www.example.com/home and it works perfectly. It can handle easily 300 concurrent users. But when I test www.example.com it breaks in the first few seconds which means it’s not serving the cached page. This is expected since Varnish doesn't know I want to serve /home.
So, I tried several ways to "tell" Varnish to serve /home when the main domain is accessed but I can not get it right.
I tried to use rules of “regsub” and “set req.http.host” as the one bellow but couldn’t get it working the way I need. I would very much appreciate if any one could point me in the right direction.
sub vcl_recv {
if (req.http.host == "example.com") {
set req.http.host = "example.com";
set req.url = regsub(req.url, "", "/home");
}
}
Thanks!