Browser timing out attempting to load images

Posted by notJim on Stack Overflow See other posts from Stack Overflow or by notJim
Published on 2010-05-26T01:33:17Z Indexed on 2010/05/26 8:41 UTC
Read the original article Hit count: 198

Filed under:
|
|
|
|

I've got a page on a webapp that has about 13 images that are generated by my application, which is written in the Kohana PHP framework. The images are actually graphs. They are cached so they are only generated once, but the first time the user visits the page, and the images all have to be generated, about half of the images don't load in the browser. Once the page has been requested once and images are cached, they all load successfully.

Doing some ad-hoc testing, if I load an individual image in the browser, it takes from 450-700 ms to load with an empty cache (I checked this using Google Chrome's resource tracking feature). For reference, it takes around 90-150 ms to load a cached image.

Even if the image cache is empty, I have the data and some of the application's startup tasks cached, so that after the first request, none of that data needs to be fetched.

My questions are:

  1. Why are the images failing to load? It seems like the browser just decides not to download the image after a certain point, rather than waiting for them all to finish loading.
  2. What can I do to get them to load the first time, with an empty cache?
    Obviously one option is to decrease the load times, and I could figure out how to do that by profiling the app, but are there other options?

As I mentioned, the app is in the Kohana PHP framework, and it's running on Apache. As an aside, I've solved this problem for now by fetching the page as soon as the data is available (it comes from a batch process), so that the images are always cached by the time the user sees them. That feels like a kludgey solution to me, though, and I'm curious about what's actually going on.

© Stack Overflow or respective owner

Related posts about php

Related posts about Performance