Caching Images

D

Dave Griffiths

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
 
A

APB

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)
 
G

Grant Wagner

Dave said:
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

"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.jpg" 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.jpg";
</script>
</head>
<body onload="document.images['placeHolder'].src = 'myHugeImage.jpg';">
<img name="placeHolder" src="someSmallImage.jpg">
</body>

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

--
| Grant Wagner <[email protected]>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_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-developer/upgrade_2.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top