store images in cache

joe_pool_is

Well-known member
Joined
Jan 18, 2004
Messages
451
Location
Texas
Ive got a website I am building that includes several large images.

Is there a way that I could store those images when the page initially loads, then reuse this info to populate places on my various different pages as they are loaded? A simple example would be nice, also.
 
Are the images physical files on the servers disk or are they being dynamically generated someway? If they are just files then the normal server os should handle the caching on the server side and the browser handle caching on the client side.
 
PlausiblyDamp said:
Are the images physical files on the servers disk or are they being dynamically generated someway? If they are just files then the normal server os should handle the caching on the server side and the browser handle caching on the client side.
The images are physical files on the server disk.

In its current configuration, the "developer" (a graphics artist) loaded all of the images using JavaScript (i.e. pic5 = new Image(); pic5.src = "images/map5.jpg"). The problem with this is that JavaScript isnt smart enough to realize that those images are already cached ...or so it seems. Therefore, anytime the page is refreshed, the JavaScript reloads all of the images.

Ive been asked to find a way to improve upon the graphics artists code, but since I do not use ASP.NET, JavaScript, or HTML as often as I use C++, Im not sure what the best approach would be. I believe a test for "IsPostBack" would work on ASP.NET systems, but is there something similar in Classic ASP or for JavaScript? The company might frown upon my solution were for them to migrate to ASP.NET servers.
 
One possible solution is to not use JavaScript when it isnt needed. If the page is just displaying these images then simply using an img tag would work (after all it did for many years before JavaScript existed).

Out of interest are you sure the images are being sent everytime and not cached anywhere on the browser?
 
PlausiblyDamp said:
One possible solution is to not use JavaScript when it isnt needed. If the page is just displaying these images then simply using an img tag would work (after all it did for many years before JavaScript existed).
The company populates innerHTML elements with these images which switch back and forth when Customers mouse over different links. The problem comes when the Customer clicks the link to pull up the information on that particular item, because the JavaScript wants to reload all of the images.

PlausiblyDamp (cont.) said:
Out of interest are you sure the images are being sent everytime and not cached anywhere on the browser?
Thats what I was told, and Ive been asked to fix it. If you know of a particular way to tell JavaScript to load an image from cache instead of downloading it, please enlighten me! Browsers are *supposed* to do this, but it doesnt often happen.

Is there a way I could load all the images into a separate file and have that file remain loaded for the duration? For example, what if I turned their site into something that used frames, and loaded all of the images in the main form? Would there be a way for the Child pages to access images from the Parent frame? Then, when a Customer clicked a link associated with an image in an innerHTML document, the page could reload, but still know that the images are already sitting there waiting for them in the Parent. I dont know how to access an image on the Parent form, though, and Im not sure how Id put the images on the Parent form if the Parent form didnt really have a body tag.

Im just trying to brainstorm some ideas, and so far that is the best Ive come up with.
 
Back
Top