.NET Answers

ASP.NET, HTML, CSS, Visual Studio, CSharp, VB.NET and other programming items of interest.
Subscribe
  • Home
  • About Me
  • Advertising
  • Click Here to Ask a question
    • Privacy Policy
  • Site Map

Catching Data for Performance

July 02, 2008 By: Dave

 

I got a question the other day from a gentleman who is writing an application for YouTube.  His problem is that he’s gathering data from the YouTube web site and redisplaying it in his web application.  Once he has it, he then allows the user to page it and sort it.  His question was, “Is there any way of caching the data so that I don’t have to go back to the YouTube web site each time?”

There are actually several ways of dealing with this issue.

ObjectDataSource

If you are looking for an automatic way of handling this problem.  Look no further than the ObjectDataSource.  There are several properties hanging off of this that can help you:

EnableCaching Set this to true to enable caching at the ObjectDataSource level.
CacheDuration Length of time, in seconds, to cache the data.  You can also specify “Infinite” if you want to hold the data forever.
CacheExpirationPolicy Absolute or Sliding.  Controls if duration is from first call to the server (absolute) or last call to the server (sliding)
CacheKeyDependancy Allows you to programmatically expire they cache based on some key.

 

This method stores the data on the server and associates it with the page.  Somewhat memory intensive as is the next method.

 

Session Variables

You could also do everything programmatically and push the DataSet into a session variable.  To do this, you’ll want to create a key for specific search conditions, if any and store the DataSet as the value.

You may be thinking at this point, “this is more work, and just as memory intensive as using the ObjectDataSource.”  And you would be right if you used an InProc session variable to do this.  But, if you used a Session Server, specifically the SQL Session Server, to do this, you can off load the memory onto the database but still have the advantage of caching your data.

 

Store It

Depending on the data you are caching and how long it is good for, you might want to consider storing the data into your own database.  In the case of the question that was asked of me, this might be the best solution.  You could retrieve the data once and use it for every visitor for hours after.  While implementing Caching on the ObjectDataSource and using Session Variables are both methods that only benefit one user at a time.  Storing the data into a database benefits all of the users.  The obvious down side to mirroring the data like this is that it takes considerably more effort to code and the first request will take considerably longer to process.  But, there are ways of dealing with those problems as well.

 

Depending on the data you are trying to deal with, one of these methods should work for you.

 

Other places talking about ObjectDataSource:

  • Using ASP.NET Dynamic Data with ObjectDataSource

    - ObjectDataSource: your page uses an ObjectDataSource to have ASP.NET interact with your entity and business layer classes. You tell the data source exactly which method to call for each CRUD operation. …

  • Building Custom Paging with LINQ, ListView, DataPager and …

    - To be able to use ObjectDataSource in proper way, I made a simple Business Class that wrap the NorthwindDataContext -Northwind LINQ to SQL Class- and called it NorthwindProducts. This class basically contain 2 static methods one that …

  • Exporting to Excel directly from ObjectDataSource?

    - Summary: I have a gridview with an objectdatasource. … Dim tw As New IO.StringWriter … Dim frm As HtmlForm = New HtmlForm … I dislike that I have to pull from the Gridview at all. …

 

Other places talking about Sessions:

  • how to clear the session while loging out(ASP.Net,C#)

    - Hi, I would like to know how to clear the session while logging out from the application…ie even if i press back button it should say “Session Expired”….

  • Handling Session Timeout

    - The first time you put anything into Session State, ASP.NET creates the Session cookie called ASP.NET_SessionId. When Session Timeout occurs the ASP.NET_SessionId cookie is deleted BUT the Session itself is not. …

If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!

Most Commented Post

  • Object Oriented Programming has Failed Us
  • Microsoft’s Biggest Mistake with ASP.NET
  • WordPress w/ Forms Authentication on IIS6
Bookmark to:

Add to Del.icio.us Add to digg Add to DotNetKicks Add to DZone Add to Facebook Add to Slashdot Add to Stumble Upon Add to Technorati
Hide Sites

Comments are closed.

← DotNetNuke – Avoiding Container Collision
DotNetNuke Skinning – Dealing with Images →
  • Search

  • Subscribe

    U COMMENT
    I FOLLOW

    Subscribe in a reader

    OR

    Subscribe via e-mail

    Enter your email address: 

    Delivered by FeedBurner

     

  • Follow Me

    • Twitter
    • FaceBook
    • Digg
    • StumbleUpon
    • Propeller
    • Delicious
    • Plaxo

     

  • Recent Posts

    • ASUS Eee PC 1005HA-PU1X-BK Black Netbook
    • jQuery – Date Picker
    • Using VB.NET From CSharp
    • iTextSharp – Adding Images
    • Hungarian Notation – Use What Works, Spit Out The Bones
    • Pre Order Windows 7
    • jQuery Dialog – With Validation Controls
    • iTextSharp – The easy way
    • Structure of my ASP.NET Web Applications
    • 35% Off Accronis True Image 2009 Home
    • VB.NET Hide Module Name
    • ASP.NET/VB.NET – Video Training
    • Does jQuery Make Us Lazy?
    • PDFs Using iTextSharp
    • Programming SEO – Ping



  • Advertise on this site through Lake Quincy Media
  • DotNetNuke Sponsor

     

    Most Valuable Blogger
  • Sponsor

  • Categories

    • Advanced CSharp
    • Advanced VB.NET
    • ASP.NET MVC
    • Did you know
    • DotNetNuke – Module Development
    • DotNetNuke – Skinning
    • internationalization
    • iTextSharp
    • jQuery
    • none
    • Seach Engine Optimization
    • Silverlight
    • SQL For Programmers
    • Twitter
    • winforms
  • Cloud

    .net ajax architecture asp.net book books containers csharp css dal dataset datasets dotnetnuke events gridview images internationalization internet explorer javascript jQuery json linq listview modules ms-sql MVC objectdatasource programming reflection seo Silverlight skinning sql testing tsql tutorial Twitter twitterizer vb.net video view Vista visual studio webservice WordPress
  • Archives

    • July 2009
    • June 2009
    • May 2009
    • April 2009
    • March 2009
    • February 2009
    • January 2009
    • December 2008
    • November 2008
    • October 2008
    • September 2008
    • August 2008
    • July 2008
    • June 2008
    • May 2008
    • April 2008
    • March 2008
    • February 2008
    • January 2008
    • December 2007
    • November 2007
    • October 2007
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
    • Privacy Policy
  • Calendar

    July 2008
    S M T W T F S
    « Jun   Aug »
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  
  • Blogroll

    • Alvin Ashcraft’s Morning Dew
    • ASP.NET Consulting
    • Life Hacker
    • Remember Anything
    • The Price of Their Toys
    • Uncategorized Thought


.NET Answers © 2007 - 2008 All Rights Reserved.
Entries and Comments.