The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Browser cache control

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
  • #30619

    I’ve just had a strange problem involving a javascript image fader and the site running out of bandwidth. The gist of it is that I left a computer running over night with Firefox (v3.6 I think) open and showing a page that had a fade/dissolve image sequence running – repeating a sequence of 5 or 6 images over and over. The next morning the website had been shut down having exceeded its bandwidth limit.

    The image fader starts with an array of image filenames (arrPicFile[]) and when the page opens it loads the first one like this…

    var elPic = document.getElementById(“mainpic”);
    if (elPic)
    elPic.src = arrPicFile[0];

    There’s obviously a load of messing about with fading the image up but that code snippet shows the interraction with the server – loading only one pic at a time so the page doesn’t have to wait for every image to load before it can start its work. After a few seconds we get the next image from the array of filenames…

    elPic.src = arrPicFile[1];

    This goes on every few seconds and when we reach the end of the array we go back to the first pic again, arrPicFile[0]. This time it should aready be in the browser’s cache and not relaoded from the server. I can see this happen by breaking the connection to the internet and, as long as every image has appeared at least once, the sequence just keeps going.

    So why did the site use up its bandwidth? Did the cached copies expire? If so is there a way to control the cache expiry time?

Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.