Solved

Making images download only once

Posted on 2001-07-29
7
184 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

690 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