Caching button data

  • Thread starter Thread starter BobLaughland
  • Start date Start date
B

BobLaughland

Hi There,

Is there a way to cache button images in ASP .NET 2.0.

What I have are buttons on my site which have 3 different images for 3
states,

1) Normal
2) Hover
3) Selected

What the issue is though is that the first time I hover over a buttton
it takes a few seconds to show the hover image because it is loading it
from the server. Same with the first time I click one of the buttons,
it is slow to show the selected image.

So yeah, can I somehow tell the page to preload all the images so that
it will be snappy.

Thanks,

Peter.
 
Thus wrote BobLaughland,
Hi There,

Is there a way to cache button images in ASP .NET 2.0.

What I have are buttons on my site which have 3 different images for 3
states,

1) Normal
2) Hover
3) Selected
What the issue is though is that the first time I hover over a buttton
it takes a few seconds to show the hover image because it is loading
it from the server. Same with the first time I click one of the
buttons, it is slow to show the selected image.

So yeah, can I somehow tell the page to preload all the images so that
it will be snappy.

You can use HTTP caching to allow browsers to retain a local copy. Unless
you serve these images through some web application component like a HttpHandler,
they should be cacheable by default.

Cheers,
 
Thanks, but I would like to kick start the process. Is there not a way
to make the browser load them up and cache them while the user is
reading through the first page of writing?

That would then mean that the first time the user hovers over any of
the buttons the hover image would appear instantly.

Anyway just wanting to make everything crisp and clean.

You are right though, as soon as the image is loaded the first time the
image remains in the browser cache.
 
Thanks Jeff, will I be able to do the javascript preload thing in a C#
ASP .NET 2.0 site?

Otherwise does anyone know how to do it in C# using ASP .NET 2.0?
 
you can use client script to preload them

<script>
var imgList = "normal|hover|selected".spilt();
var imgs = new Array();
for (var i=0; i < imgList.length; ++ i) {
var img = new Image();
img.src = "images/" + imgList + ".gif";
imgList = img;
}
</script>

-- bruce (sqlwork.com)
 
Thus wrote BobLaughland,
Thanks, but I would like to kick start the process. Is there not a way
to make the browser load them up and cache them while the user is
reading through the first page of writing?

The browser only loads what is referenced by the user or a page.

You could load the additional images from your start page using AJAX. While
the user reads the start page, the browser could could fetch more images
asynchronously -- you just wouldn't use these images on your start page afte
loading them.

Cheers,
 
Back
Top