Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not reloading images

Status
Not open for further replies.

RedRobotHero

Technical User
May 2, 2003
94
CN
So, I'm working for a catering business with an ordering page made in ASP. They want me to add images to the page.

As it stands, every time you order an item, it reloads the page. Now, if there's a lot of images on the page, how can I encourage the browser to not reload all the images each time? Usually the browser caches images, right? Will it be enough to count on that, or is there something else I should do?

I could probably make some javascript code that updates only the portion of the page that needs to change, but then the javascript would be critical to the function of the page.
 
I'm pretty sure there's JS or CSS that tells the browser to cache the images no matter what. So it stands to reason that you could also have the code tell the browser to keep using those images on reload.
 
Hi mate,

It depends on the browser and also the machine it is running on.

If the machine has a full cache, no matter what you do (short of downloading those images to the machine) you cannot do anything to force a browser to cache images or anything else. Browsers can also be configured to not store any cache.

You can set a cache header telling the browser that the page will expire in the future but nothing is guaranteed to work.

Hope this helps

Wullie


The pessimist complains about the wind. The optimist expects it to change.
The leader adjusts the sails. - John Maxwell
 
u can use this :
<---------eg. preload 2 images---------->

<script>
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
</script>
...
...
.
..

<body leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; onLoad=&quot;MM_preloadImages('/images/1.jpg','/images/1.jpg')......
.........
..
.
.
.
<---------------------end--------------->

> need more info?
:: don't click HERE ::
 
[ignore]lebisol try that again with
Code:
 and
(as seen in my sig), looks like its breaking cos of a in your code :)[/ignore]

Also I think that will make absolutely no difference to whether the images are cached. And in reference to the original question I think there is no way to force image-caching.. but don't worry almost all users should cache their images by default, either on their PC or at their ISP's level. I don't think you want to cache a dynamically generated page either (as wullie suggested) - generally you want them to be not cached.

Let us know if you find a reliable way though :)


Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
nope not too bulky since it is reused and I am used to it ( I like my editor to 'remember it' rather than me trying to cut down on 1 line of code & make spelling.errors)
.....and yes I know that most users(Browsers) will cache thier images (per session or..whatever they set it to)...pre-loading is just like warming up your car at cold morrning :)
All the best!

> need more info?
:: don't click HERE ::
 
&quot;And in reference to the original question &quot;
---> Not reloading images
thread253-613560

&quot;I think there is no way to force image-caching&quot;
-- I must agree...at least I have not seen it yet
....but what do I know I am not a pro.
All the best!

> need more info?
:: don't click HERE ::
 
see that's the cool thing about web dev... you do

<script>
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a.indexOf(&quot;#&quot;)!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}
</script>
<body leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; onLoad=&quot;MM_preloadImages('/images/1.jpg','/images/1.jpg')......

and I do...

<script>
rimg1 = new Image();
rimg1.src = &quot;path/to/image.jpg&quot;;
</script>

and they achieve the same thing... love the flexibility...
 
TheConeHead (Programmer)
lebisol (IS/IT--Manageme)
:)

> need more info?
:: don't click HERE ::
 
(IS/IT--Manageme)

Are they managing you alright? ;) And sure, DW code is impossible to understand and a bit over bulky - but that's even better! TheConeHead's 2 liner is way too easy for script kiddies to steal and reuse! [3eyes]


Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
I am managed well ;-)
...in both MM_forums UNLIKE some &quot;porogrammers&quot; here [noevil]

> need more info?
:: don't click HERE ::
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top