473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Image Cache

Hi,

I've been developing an intranet application that uses IE 5.5 and have
come across a problem, well sort of.

Since the application uses frames I use an array of Image objects to
cache the image in the top frame. Now replacing an exsiting the image
source on an existing image tag is easy (ie imgTag.src =
imgArry[i].src) and there is no HTTP request back to the server.

Now expanding that concept further if I create an image tag with
javascript by using divTag.innerHTML = '<img src="imgURL">' this
created tag will make an HTTP request to the server, and since I've
all ready cached all images the server returns a 304 (not modified)
and does not return image data.

So to avoid the HTTP request I tried divTag.innerHTML = '<img src=""
onerror="func(this)" imgIndex="1">'

where

function func(ref){
ref.src =imgArry[ref.imgIndex].src];
}

therefore in this case we have an existing image tag, albeit it throws
an error, and do the normal image replace. now in this scenerio it
still makes a HTTP request.

Why does the last scenario make a HTTP request? Also is there a way to
create an image tag on the fly without it making a HTTP request?

thanks
Jul 20 '05 #1
2 2189
On 7 Jan 2004 08:42:29 -0800, jo*********@jpmorgan.com (jubes) wrote:
Since the application uses frames I use an array of Image objects to
cache the image in the top frame. Now replacing an exsiting the image
source on an existing image tag is easy (ie imgTag.src =
imgArry[i].src) and there is no HTTP request back to the server.
That would all depend on the cache settings, if the above doesn't make
an http request, then I'm surprised an innerHTML call does, I've
never seen where the 2 are not absolutely equivalent.
Why does the last scenario make a HTTP request? Also is there a way to
create an image tag on the fly without it making a HTTP request?


Nope, but IE fully honours cache settings, and you really should not
have got this far without visiting htt://www.mnot.net/cache_docs/ do
so now, and your problems will go away.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2
jubes wrote:
Since the application uses frames I use an array of Image objects to
cache the image in the top frame. Now replacing an exsiting the image
source on an existing image tag is easy (ie imgTag.src =
imgArry[i].src) and there is no HTTP request back to the server.


No matter if it's only IE, do it the standards-compliant way
wherever you can (and you can here, without breaking functionality
but with cleaning up the namespace). You may want to port it
sometime. So do not use idOrNameOfElement.src but use
document.images["idOrNameOfElement"].src. And you better test
if document.images["idOrNameOfElement"] exists before you do
that. (You should do this with idOrNameOfElement as reference,
too.)
PointedEars
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ken | last post by:
How does IE6 control the display of images? I change the content of a image file image1.jpg without changing the file name. Then jump to a new page to display it. IE6 does not displays the...
16
by: Donjuan | last post by:
Hi all I have trouble with tracking whether my image file is loaded. i use DHTML to change my image. HERE is the code: <img name="someimage" src="1.jpg"...
2
by: Marwin | last post by:
Hi all, I have a database with 40GB of binary objects stored in image columns in two tables. Our database server is also used for another 15 databases. SQL Server caches the image-column,...
1
by: Giggle Girl | last post by:
Hello, I am helping to design a web application that uses 167 little icons on various pages in a framed environment. As is, the app loads each icon on a page by page basis, and if an image...
2
by: thehuby | last post by:
I am building a CMS and as part of it a user can upload an image. Once uploaded I am displaying the image. If the user then decides they want to replace the image with another I get a caching...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
6
by: Mark Denardo | last post by:
I created a Web Image "<asp:Image ID="Image1" ..." that my code behind set to a certain image file say image1.jpg =Image1.ImageUrl = "<rel_path>/image1.jpg"; which set the image ok, but then I...
11
by: Jerry J | last post by:
How can I get an asp:Image to refresh when a user uploads a different jpg. I disabled caching using this command on Page_Load(): Response.Cache.SetCacheability(HttpCacheability.No Cache); but it...
2
by: jeanray | last post by:
I have a site made entirely with AJAX, base PhP and MySQL, so the is only one page (index.php). The user goes through various selections and an image is formed (on the server), then sent back to the...
4
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm building an ASP.NET 2.0 web-app for a customer. The customer wants a background image that's 124k in size as the background for each page. I've recommended they use a smaller-size image,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.