Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Making images download only once

Posted on 2001-07-29
7
Medium Priority
?
188 Views
Last Modified: 2010-04-09
I have a list that I'm building dynamically that contains about 200 entries. Beside each item, I place 3 hyperlinked images. It looks to me like web browsers are downloading these 3 images once for each record, not once for each page. This makes the download time on a modem around 1 minute.

The html for the page is about 5K, the images are around 2k combines, the reported page size when it downloads is about 200 kb.

- The images are included using the usual <img src> tags.
- The list is build in a Perl script that is included using SSI
- The webserver is Apache for linux

Anyone know how I can get the browser to download these images only once?

Thanks!
0
Comment
Question by:GeoffHart
7 Comments
 
LVL 2

Expert Comment

by:egbservices
ID: 6332961
What about pre-loading the images...

Pre-load an image...
<script>
image1 = new Image();
image1.src = "some.gif";
</script>
This will load them into the cache... ready for display.
0
 
LVL 2

Expert Comment

by:egbservices
ID: 6332966
What about pre-loading the images...

Pre-load an image...
<script>
image1 = new Image();
image1.src = "some.gif";
</script>
This will load them into the cache... ready for display.
0
 
LVL 2

Expert Comment

by:egbservices
ID: 6332972
Or this way if pre-loading does the job...
<script language="JavaScript"><!--
     if (document.images) {
     var img1 = new Image();
     img1.src = 'http://www.domain.com/path/image1.gif';
     var img2 = new Image();
     img2.src = 'http://www.domain.com/path/image2.gif';
     // ... etc for all your other images
     }
// --></script>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Accepted Solution

by:
coreyti earned 400 total points
ID: 6333041
If the three images are the same for each entry (you are reusing the same 3 images 200 times over AND the uri path is the same each time), then that shouldn't be your problem.

Taking a stab in the dark, I'd guess that the script is the trouble. The external html maybe only 5k, but having a dynamic section included into it means that the script has to run and the results effectively pasted into the html before it is shipped of to the client.

Some sample code might help us track it down more.

-corey
0
 
LVL 1

Expert Comment

by:yitz99
ID: 6333228
Agreeing with Corey...

test your script by printing the time in HTML comments at the beginning and end.  

Why not post your URL?
0
 
LVL 2

Expert Comment

by:englishman
ID: 6337828
Or, copy the source after it has downloaded, paste it into a new html page and view it to see how long it takes without script processing.
0
 
LVL 1

Author Comment

by:GeoffHart
ID: 6342718
I couldn't post the actual script, since it is build using data from a confidential database. When I was producing the test script which I was going to link to demonstrate the problem, I noticed the error.

It turns out, the HTML page was only 5 kb and the 3 images were downloaded once. What happened is that the script also produces a javascript which consists of around ten lines. This got included one level of brackets too deep, and got spooled out 200 times onto the page (140kb of code!).

I also checked the script generation time, it was < 1 second.

Thanks everyone for your help.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question