By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,885 Members | 1,445 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,885 IT Pros & Developers. It's quick & easy.

Caching Images

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/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)

"Dave Griffiths" <da**@daveg.co.uk> ha scritto nel messaggio news:pa****************************@daveg.co.uk...
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

Jul 20 '05 #2

P: n/a
Dave Griffiths wrote:
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 <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* 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
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.