Caching Images

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Griffiths

    #1

    Caching Images

    Hi all

    Very new to JavaScript, I am trying to cache a number of images as the
    page loads, is there a max number of images or memory usage before the
    browser stops caching.

    My PC has 1G ram so if it's a physical memory constraint then I think I am
    away from that. I am trying to cache about 600K images, (this if for an
    intranet so the page load time is fast) but I need the speed of cached
    images for the page to work correctly. I seem to be able to only cache
    about 400K.

    Is this a limit or is there a trick I need to know.

    Thanks DaveG
  • APB

    #2
    Re: Caching Images

    I suppose the limit depends on the browser's settings for the cached data (on disk).

    I once created a page with 100 A4 scans. Needless to say the TaskManager reported a huge increase in IE's memory usage... and the
    whole system blocked while trying to allocate more virtual memory.

    If your on an Intranet, I guess caching too many images quickly outperforms loading them on-demand.

    Alex.

    --
    _______________ _______________ _______________ ______________
    a p bertolini

    "Se Dio è perfetto, perché ha creato le funzioni discontinue?"

    #ICQ: 10681264
    (www.webwarrior.org)

    "Dave Griffiths" <dave@daveg.co. uk> ha scritto nel messaggio news:pan.2003.0 8.24.10.45.07.3 08171@daveg.co. uk...[color=blue]
    > Hi all
    >
    > Very new to JavaScript, I am trying to cache a number of images as the
    > page loads, is there a max number of images or memory usage before the
    > browser stops caching.
    >
    > My PC has 1G ram so if it's a physical memory constraint then I think I am
    > away from that. I am trying to cache about 600K images, (this if for an
    > intranet so the page load time is fast) but I need the speed of cached
    > images for the page to work correctly. I seem to be able to only cache
    > about 400K.
    >
    > Is this a limit or is there a trick I need to know.
    >
    > Thanks DaveG[/color]


    Comment

    • Grant Wagner

      #3
      Re: Caching Images

      Dave Griffiths wrote:
      [color=blue]
      > Hi all
      >
      > Very new to JavaScript, I am trying to cache a number of images as the
      > page loads, is there a max number of images or memory usage before the
      > browser stops caching.
      >
      > My PC has 1G ram so if it's a physical memory constraint then I think I am
      > away from that. I am trying to cache about 600K images, (this if for an
      > intranet so the page load time is fast) but I need the speed of cached
      > images for the page to work correctly. I seem to be able to only cache
      > about 400K.
      >
      > Is this a limit or is there a trick I need to know.
      >
      > Thanks DaveG[/color]

      "Caching images" refers to storing the image in the browser's Temporary
      Internet Files or Browser Cache storage area before it's needed, so when you
      request it later, it loads quickly because it is already stored on the local
      disk.

      (new Image()).src = 'whatever.jpg';

      is intended to store "whatever.j pg" on your local hard disk, that
      functionality is managed entirely by the browser, based on the HTTP headers
      sent with the image and the browser's own cache settings. Whether the browser
      stores the image in RAM is entirely browser dependant but is also irrelevant
      since it has no impact on what you are trying to do.

      There are a few possibilities:

      1) your HTTP server's settings are such that those extremely large images are
      being sent to the browser with headers that indicate they should not be cached

      2) your Temporary Internet Files or Browser Cache settings are so low that
      there simply isn't enough available space to cache the images to disk

      3) it's taking longer to download that 600Kb image then the time before you
      use it. As a result, it appears to not be "cached" because it is still being
      downloaded when it's being used. A simple example of this would be:

      <head>
      <script type="text/javascript">
      // I'm so clever I'm caching myHugeImage
      (new Image()).src = "myHugeImage.jp g";
      </script>
      </head>
      <body onload="documen t.images['placeHolder'].src = 'myHugeImage.jp g';">
      <img name="placeHold er" src="someSmallI mage.jpg">
      </body>

      In the above code, it doesn't matter that you're being clever and pre-caching
      "myHugeImage.jp g" because you're using it /long/ before it's had time to be
      downloaded to the browser.

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      *


      * Internet Explorer DOM Reference available at:
      *
      http://msdn.microsoft.com/workshop/a...ence_entry.asp

      * Netscape 6/7 DOM Reference available at:
      * http://www.mozilla.org/docs/dom/domref/
      * Tips for upgrading JavaScript for Netscape 7 / Mozilla
      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


      Comment

      Working...