Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / November 2006

Tip: Looking for answers? Try searching our database.

IHttpHandler and Caching

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 26 Nov 2006 19:13 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.