Hi,
Ive got a .ashx file which produces an image (useage: <img
src="myHandler.ashx" />)
What do I need to do to make it cache? Every time my page reloads it
recreates the image (a slow process), and i have a lot of these per page.
The image-producing code doesn't NEED to be in a handler (in case anyone
has a better suggestion)
Thanks
Andrew
Dave Sexton - 27 Nov 2006 03:00 GMT
Hi Andrew,
In the future you may get better responses if you post ASP.NET questions to
the microsoft.public.dotnet.framework.aspnet newsgroup.
If you're generating the image on-the-fly then you can cache the result
programmatically:
public Bitmap YourImage
{
get
{
if (Cache["YourImageKey"] == null)
Cache["YourImageKey"] = GenerateYourImage();
return (Bitmap) Cache["YourImageKey"];
}
}
"Caching Application Data"
http://msdn2.microsoft.com/en-us/library/6hbbsfk6.aspx
To allow IIS, proxy servers and the user agent (web browser) to cache the
request output you can use the following code, for example:
Response.Cache.SetCacheability(HttpCacheability.Public);
"How To: Set a Page's Cacheability Programmatically"
http://msdn2.microsoft.com/en-us/library/z852zf6b.aspx

Signature
Dave Sexton
> Hi,
>
[quoted text clipped - 10 lines]
>
> Andrew