Images TTFB very slow before render

Hey guys,

I got this weird issue where images first byte is really really slow before the page render start.

You can see an example here: http://www.webpagetest.org/result/140806_KB_10A3/1/details/

I can’t understand how this is happening.

  • We use cloudflare as a cdn

Cloudflare supports SPDY (which is a very good thing) so the waterfalls might not look like you’re used to seeing. With SPDY the browser can send requests for everything it needs all at once and then the server can deliver them as they become available (sometimes in parallel and with hints about priorities provided by the client).

When that happens you usually see a lot of requests all starting around the same time but taking different amounts of time for the responses as they get delivered over the connection.

If you look down at the bandwidth chart at the bottom of the waterfall you can see that it’s completely pegged so they are basically delivering the images as fast as the connection allows for.

That said, there are a couple of things you should be aware of:

1 - Sharding domains is a bad idea with SPDY (static1 and static2). You’re a lot better off just using a single domain. The current releases of all of the major browsers support SPDY (well, Safari in the fall with version 8): SPDY protocol | Can I use... Support tables for HTML5, CSS3, etc so it’s probably best to optimize for that case given that it will still work fine for the non-SPDY case.

2 - When you get off of staging will your main server also go through cloudflare? If so then your best bet is to not have a separate static domain at all and serve everything from the same domain.