Caching Made Simple - A Practical Birdseye Overview
page 3 of 8
by Michael Libby
Feedback
Average Rating: 
Views (Total / Last 10 Days): 138988/ 85

Where, What, and When to Use Caching

Where Caching Takes Place

Where caching takes place includes the following primary locations:

  • Server cache is used to quickly retrieve web page content, either raw data or the output of previously generated web pages, thus saving server load for many users.
  • Proxy cache utilizes specialized network hardware located in-between the client and the server to retrieve entire web pages and referenced files for multiple computers, thus saving both server load and bandwidth.
  • Client cache (also known as browser cache) is used to retrieve entire web pages and referenced files at the client, thus saving both server load and bandwidth for a single user.

What Types of Caching Are Available

What types of caching are available depends primarily on the type of data to be stored:

  • Data caching stores arbitrary data such as simple strings, custom objects, and complex data objects like array lists, data sets, and hash tables in server memory
  • Fragment caching stores the generated output of web page portions and only at the server.
  • Output caching stores the generated output of an entire web page at the server or the client.
  • Image caching stores images in client-side cache.

When to Use Caching

When to use each caching process is based largely upon limitations. Typically the advantages of all caching processes are desired, but are often ruled out based upon limitations. The following describes when to use each caching process based upon advantages and limitations:

  • Data caching should be used to store frequently accessed data in server memory. However, do not store so much data that it overburdens server memory, adversely affecting the entire computer performance. Data caching is the most flexible form of cache because it can be changed on any web request. It offers the slowest overall performance improvement compared to other forms of caching because web page content must be regenerated with every request.
  • Output caching is used to store the generated output of an entire web page at the server or the client. Refreshing items in both of these storage locations depends primarily on expiration periods. If data changes before the expiration period ends then the client will view its obsolete cached representation. For this reason it is best to use output caching when data changes can be synchronized with expiration periods. Client and server caching also have differences.Server cache can store several versions of a web page, whereas the client cache can only store a single version. On the other hand, client cache can store more data because it does not tie up server memory. Client output caching is the fastest form of caching because it does not require a round trip to the server. Server output caching is the next fastest form of caching because the web page is not regenerated.
  • Fragment caching is used to store the generated output of web page portions and only at the server. Refreshing fragment caching depends primarily on expiration periods which, like output caching, can cause cached data to become obsolete. Fragment caching can store several versions of web page portions. Fragment caching also requires a round trip to the server.
  • Image caching is controlled through Internet Information Server (IIS) and not ASP.NET. By default, images that are returned from IIS to the client are cached but have no expiration date, which means that the client will continually issue requests to the server to ascertain whether the original image has been modified. To prevent such numerous requests, images can be placed within a directory marked by IIS as Enable Content Expiration. These images will be given a future expiration date, which means that the client will not issue requests to the server until its cached copy of the image expires.
    Note: IIS Enable Content Expiration is applicable to other files as well as images. However, other files such as .js and .css files are automatically given expiration dates, images are not.

Caching Summary

The following chart summarizes each of these caching processes, locations, advantages, and limitations:

 


View Entire Article

User Comments

Title: Good one though problem with firefox   
Name: dotnetguts
Date: 2009-05-03 9:09:10 AM
Comment:
Thanks for good article, I have tried instruction mentioned in article, but it is still not working for firefox, any idea? to make it work.

DotNetGuts
http://dotnetguts.blogspot.com
Title: good one   
Name: vijay chand
Date: 2009-02-09 4:15:13 AM
Comment:
The above article has given me some knowledgeable thing
Title: REg. getting URLs of all visited Sites   
Name: Ad
Date: 2007-08-13 9:24:34 AM
Comment:
Hi

In the txt file, I only get the URL of this website, nothing more. Could you let me know what I m missing.
This is what I get -- 127.0.0.1;/CachingMadeSimple/OutputCachingClient.aspx;8/13/2007 6:46:57 PM

Also, could u explain the 2 minute time limit u hv put?
regards
Ad
Title: Software Enginner   
Name: Chintan Mehta
Date: 2007-07-02 9:55:09 AM
Comment:
This tutorial is very good but i want tutorial which describe actual in which scenario we have to use which type of caching. say in which condition fragment caching is usefull, in which condition data caching is usefull please describe with example if it is possible.

Thankyou.
Title: Software Engineer   
Name: Mudassar
Date: 2006-08-10 5:12:29 PM
Comment:
Excellent
Title: Great Article   
Name: Susan Dawson (Israel)
Date: 2006-04-08 9:17:06 PM
Comment:
This is one of many great articles you've written. I enjoy your easy to follow step by step articles. You are on my must read list.

Susan.
Title: Re: Images without roundtrip   
Name: Michael Libby
Date: 2006-01-31 10:12:32 AM
Comment:
Hi Fabio,
Regarding, "Copy your images to the ImagesCached directory and change all corresponding HTML references". This means that if your image directory changed then you must also change the source for your HTML Image Tag. For example, change the HTML IMG tag's src from src='NonCachedImgDir/MyImg.jpg' to src='CacheImgDir/MyImg.jpg'.
Title: images without roundtrip   
Name: Fabio Rauh
Date: 2006-01-31 7:21:57 AM
Comment:
Hi, I read your article and I´ve a doubt about how to cache images without roundtrip modification checking
I did not understand the step 7, what u mean "change" all corresponding html references. What do I have to do?
Thank you

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-06-20 7:25:35 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search