Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: ASP.NET
Expertise: Intermediate
May 5, 2009

Cache Dynamically Generated Images for Quick Page Response

If you have an image gallery with dynamically generated thumbnails, you should make sure to tell the browser to cache the thumbnails. If you don't, the page will download each image every time the browser visits, which stresses the CPU unnecessarily and causes the page to take longer to load. In contrast, when images are in the browser's cache, the page loads far faster.

If your image gallery contains multiple pages, the chances are good that users will visit the same page more than once. For returning visitors, the chances are even higher.

To enable browser caching, set the Last-Modified header in the .aspx or .ashx that you use to generate the thumbnails, using a date value so that the page always appears unmodified to the browser. Here's an example that sets the last modified date to one year ago:

Response.Cache.SetLastModified(DateTime.Now.AddYears(-1));
Srinath MS
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap