tags:

views:

63

answers:

1

I've setup varnish to sit in front of a tomcat server. What I've noticed is that Varnish seems to wait for the complete page to load (all css, js, etc) before it sends any response to the browser.

This causes a huge lag before the user sees anything. If I bypass Varnish and go directly to the site, it responds immediately.

While the total page load time might be similar, the perception is that the site is slow.

Has anyone faced this?

A: 

With the complete page to load (all css, js, etc) you mean only embedded js and css resources, am I right? Varnish will buffer (and hopefully store) a response as a whole, before sending it to the client. If your back-end sends a response incrementally (e.g. chunked), a non-cached page might appear slower because it's only delivered by varnish after the back-end has sent its last piece.

If this is a problem, change the technical design of your application. Make sure most requests can be served from cache (these pages will be really fast) and externalize js & css resources (browser cache avoids doing requests at all). If there's only a small portion of your page that's slow and badly cacheable, load it asynchronously (e.g. Ajax).

There's also the concept of incremental rendering (a browser re-rendering pages as more resources become available), but I don't see how Varnish would change this behavior.

ivy