Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Output Caching or just Caching is one of those terms you're going to hear quite a bit in ASP.NET, there's been some changes and some enhancements made in ASP.NET 4 so as a result you're likely going to see something about this on the exam. And again, I say this a lot, but they're not going to ask you what is Caching and then give you these three simple choices to choose from. They're going to give you a scenario and you'll have to understand how Caching works, what it does, what are the advantages and the disadvantages and it'll be part of another scenario, you know, a larger picture problem solution type thing and you'll just have to see if the Caching portion fits with everything else. Okay. So in this video I want to talk about Output Caching in general to help you get through those parts of the exam. And then in some separate videos, we'll go a little deeper and talk about Extensible Output Caching and those sorts of things. So first of all Caching, what is it? Well it's when we know we have data that a lot of people are going to need repeatedly. And so rather than go through the process of having this data get compiled and served out and consume all the resources on the server, why don't we just grab that data, compile it one time, get it in a final form and stick it somewhere that we can grab it really quick and serve it out. Now a great place to put this is in RAM, a Random Access Memory on the server. So let's say we've got a home page that everybody hits all day long. Well why make this thing go through all the ASP.NET Pipeline and on and on and on and all that stuff and you know, do all kind of magic and call databases, why don't we just Cache that home page, put it in RAM and every time somebody hits the website, it just serves it right back out of RAM very quickly. This is a great idea. So what are the advantages here? Pretty obvious. The requested data gets returned to you very, very quickly. There's fewer resources are required on the server to return the data, so we're making the server a lot more responsive to things that it needs to be responsive to, like, you know, different unique or other requests that come in. So the disadvantages are very real and these are the things you need to watch because, you need to be able to determine on the exam, what are the problems? What are the shortcomings of Caching that may or may not solve the problem at hand and give you a solution that makes everybody happy? This is going to be the same way in the real world. If you're trying to design an ASP.NET solution, you need to understand whether Output Caching's going to help you or hurt you. So what are some disadvantages of Output Caching? Well you're data can become stale. Let's say that we Cache the home page but something changes, something very important changes on the home page but our data never gets updated. So for half a day all of our clients are seeing old, outdated, what we call stale data alright? So that's not good. And the data maybe requested in various forms. If I Cache a page where the individual user puts in like a Customer ID and a date range, well that's not going to be very good because the Cache is not going to be hit very often because every new customer's going to change the page and so we're just going to waste a lot of memory and not serve them back and all those sorts of things. So that's the main thing you want to watch. Can the data become stale? Are we dealing with kind of very, you know, hot data that's changing quite a bit or is the end-user going to request this data in so many different forms, that it's going to be impossible to put one in memory and serve enough people? Let's talk about ASP.NET Output Caching. Now you have three basic options. You have Output Caching, Data Source Caching and then you have Programmatic Caching. Now let's look just a little closer at each one of these. Output Caching is where we take the end result of a web page and it gets Cached or it gets placed in memory. The duration can be set to avoid to stale records, we can determine how long that sits out there in memory before we get a refreshed page and load it into memory and then there's a Vary by Param Attribute. Now Vary by Param also allows you to tell the Caching mechanism that people might change based on this particular parameter and it will tell you if somebody's changes this parameter, then reload the Cache. And you're going to set this Vary by Param Attribute up there in the Page Directive when you look in your Source Code. This is where you're going to see that or your HTML is. The next type is Data Source Caching. Now anytime that we pull data from a database, we can Cache that data. So we're Caching data from the Data Source. Because if we've got a standard set of data that we query from the database every morning or throughout the day and it doesn't change a whole lot, well let's don't make 300 hits back to the database to pull that information, let's pull it once, let's Cache that and then we can grab our data from there. Now if you do an Insert, an Update or Delete Command on the database, it invalidates the Cache and makes it reload. So you can pull some data from memory, stick it out there that you pulled from the database and it will stay in memory until something changes in the underlying database. Then there's Programmatic Caching, this is pretty simple. This is where you have Programmatic Control of Cache Storage and Retrieval and you can programmatically cause it happen, cause it to refresh and all that stuff. So that's the high level overview of Output Caching, make sure you're comfortable with all this stuff and then in a separate video we'll go a little deeper here and talk about Caching Extensibility.
| Course: | Designing and Developing ASP.NET 4 Web Apps (Exam 70-519) |
| Author: | Mark Long |
| SKU: | 34292 |
| ISBN: | 978-1-61866-029-9 |
| Release Date: | 2011-12-31 |
| Duration: | 8.5 hrs / 108 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |