1

I have written a small picture script which shows a directory listing with thumbnails and also previews of the pictures.

In some cases, when you click through several image previews (you can also use the arrow keys left/right to do that faster), some images don't fully load (and they are only shown partly then).

I think this has started to appear more often since I am preloading the next few pictures but it also has appeared before. This also occurs most often if you switch the images very fast.

I wonder why this appears and how I can avoid this. I guess that the browser somehow looses some connection to the server (or the server closes it unexpectedly for some reason). Thus I tried to work around this by setting Content-Length (and I was hoping that the browser would reconnect automatically if the file was not received fully) but that didn't helped.

Also, in the browser, a normal reload of the page doesn't help, I have to force a full reload.

Albert
  • 65,406
  • 61
  • 242
  • 386
  • Can't repeat this behaviour in IE8/WinXP-SP3 - what browser are you using? – DaveRandom Aug 22 '11 at 11:59
  • @DaveRandom: Chrome. But I have also seen it in Firefox. Right now, I also cannot reproduce it. I don't really have found any reliable way to reproduce it. However, it seems to occur more often under high load. – Albert Aug 22 '11 at 12:04
  • Also, I would do this with AJAX rather than the ` – DaveRandom Aug 22 '11 at 12:08
  • Sending it as base64 would waste much bandwidth. Also, the user should be able to switch the image even if the prefetch is not completed. Also, I want to update the URL for each new picture. I think on some browser, I cannot avoid a page reload then. – Albert Aug 22 '11 at 12:12
  • That is a good enough set of reasons not to use AJAX, fair enough. Maybe you could give the iframe a `window.onload` and not refresh the page until that has fired? – DaveRandom Aug 22 '11 at 12:14
  • What do you mean by refreshing the page? The iframe loading/prefetching is already done in `window.onload`. Also, the user could switch the image anyway also in the case the iframes aren't fully loaded. I also think this is not the problem as it seems to correctly reload the pictures in such cases. It looked like it would loose the connection in the case where the images were only partly loaded. – Albert Aug 22 '11 at 12:22
  • 1
    Sorry, when I say 'refresh the page' what I mean is 'change the url to the next image'. Should have been clearer on that. And I think what you are getting at is that this would slow down navigation when you skip multiple images because each page loads 3 images (this one, last one, next one), which it would because it does... if you follow. This is probably not the right solution, you are right. I would probably get Wireshark out next to see what is actually happening when you have the problem - i.e. who closes the connection early, server or client (if either). – DaveRandom Aug 22 '11 at 12:28

0 Answers0