Solved

Making images download only once

Posted on 2001-07-29
7
177 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Accepted Solution

by:
coreyti earned 100 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Showing your events from Google Calendar in Google Maps Why? I travel all week and I thought it would be ideal if staff in office knew where I was based on my calendar. (OK real reason: my son wanted to see where I would be working, and I thoug…
This article discusses four methods for overlaying images in a container on a web page
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now