Google Search

Google
 

Tuesday, May 27, 2008

Video: How Do I: Make use of Caching?

Presenter:Scott Stanfield

Watch a demonstration of Page Output Caching followed by an overview of the new Database Caching support for SQL Server 2000 and SQL Server 2005.


Click here to go to original video page

The following text is a software generated transcript of the video. Click on a minute link to jump to a location within the video

Minute 0

Welcome to this ASP net video on caching this is part one of two parts work in a cover page level caching into the new table caching features that are supported in SQL Server 2000 and SQL Server 2005 to get started on a build a simple new website common Visual Basic and the first thing I want to show you is cashing in a single page level only and first women do is simply spit out the the current date time on response right on the system date time now is to make sure it s working in a page level caching is going to allow us to tell ASP net and not to retransmit or re re processes file every time s can be cached for us notice would hit refresh the time is ticking up so what s a couple changes from the remove this
Minute 1

Because I have little bit nicer control ready to go direct call this a time label is to show the same date and time does give you will do nicely for more have a nicer format to a tank so that new control looks like this so whatever hit refresh you can see the little green bar sticking up to indicate how the seconds has elapsed that it was a nice visual clue as to when the page actually refreshes succubus running and go back and add on the future that s been around since it s been a net 1 0 days in its page level output caching so that s a special directive I adhere to the page right there and I need is set to things the duration of the cash I ll set it to five seconds and will have it
Minute 2

Apply the caching to every page irrespective of the query string is passed them so knowing a refresh of the one for 47 because of the next five seconds and staying as is their disturbance to 52 so that s page level output caching now caching is great to wear really shows its some benefits to site is when you re doing some fairly heavy processing on the back and maybe making a call to a database and assorted hat in right now on the changes cash to 20 seconds and now let s go in connector system to a database to connect our website to a database that s running in SQL Server 2005 were using 2005 instead of SQL Server express because it can easily show the tracing that s going on behind the scenes were all the communication with SQL Server and that is on a different computer my main computer desk Sele have created an account for me the database will use a simple nor
Minute 3

Ones could cohabitate a connection string right now and copy that to the clipboard and put it inside my web config file sweater connection strings normally this is added for me to use one of the wizards in this case have to put in by hand and add a connection string which as we just saw an add a password directly now this is not best practices however you can encrypt this username and password combination will show that in the tips and tricks video vehicles use integrated security in this case be this virtual machine and recorded a demo on is not on the same box as the database and finally skims connection string and name to good salutes use that in the back tour page on a code to sum up by hand found many two things in a SQL data source that represents our
Minute 4

In the talks to the database and that s going to run on the server and to see the connection string for the Summit the connection string comes from the connection strings in the region when it is added to find a SQL select statement selectman looks like Omega three columns from the customers table customer ID company name and contact name turns that you need that DBO to clarify the schema name from the database that s this crucial in one of the that the built in SQL Server 2005 database caching so let s couldn t see it anymore think so ever connection now need a data grid given ID and also server control and the data source ID is the one above it
Minute 5

Guess one that should be good to look at it under the sun was at the cache duration of 20 seconds so when you refresh it s not making a query back to the database in fact we can switch over this profile are now enabled that they cleared out and we go back to her page to refresh no search no database traffic going back to the system so we had to wait for 20 seconds to lapse and there s her query now this is a great simple way of doing data caching however there is a problem if the state it somehow changes on the backend you want this page that the cached version of this page to be thrown away in refresh immediately said something that s difficult to do in the past is now easily supported with A s got meant to point out that Teddy can assure you now works both on SQL Server 2000 and 2005 to do that we first
Minute 6

To enable the database to support this table dependency caching so in the net framework 2 0 there is a commandline cool ASP net read in a speech at_rich sequel that I ve are together commandline here or were going to enable the table caching for the customers table and the simple northwards database so execute that they conceded some stuff on the back and we show you what it did by going to the northwards table if I hit refresh search the customers table but now I have an extra table in SQL cache tables and also on this customer table I have a trigger that whenever there s a change to this table it right to row into this
Minute 7

Major row over here so to enable this caching I had to do two things at we ve set up for the database now need to set up a website I have to make an entry in the web config have to go to the caching and enable SQL cache dependency and enable at first true and said the polling time equal to 2000 ms and then I want to do that on the database specified as a want ad for the connection string in W which the connection string appear and I need to give it a distinct name as well and that s good for the web config and to go back or default page we need to enable that caching here on this page and that simply by adding one line per one will want here in the output cache called SQL dependency is equal to in W and the name of the table and Debbie from Northlands in W customers
Minute 8

Now to go back here and hit refresh we see we have a table with 41 seconds instance to hear the cash to go back for tracing for scroll down to the bottom we see that it s executing the database every couple seconds and the clear that for you too there is a cash bowling query another one another one but it works it works pretty well watch if we could change one a code and hit refresh have to hit that Windows 20 seconds so few changes to different company life Frost Wolf can go here and hit refresh it shows a Broadway so that that works really well fact we go back with caching you can see there are some notification back and forth at the tables changed but it worked right away some changes to my name switch back and hit refresh will get the change right away now this is great because it works with SQL Server 2000 and 2005 but
Minute 9

2005 introduces new concept called the broker service and this is a means to allow on ASP net to serve as a client to wear can be notified if there s a change and it will have set up a dialogue between its net 2 0 and SQL Server 2005 to enable that it s very easy to the reason we re showing here with SQL Server 2005 they can keep in mind that this version were showing now this can be pulling every couple of seconds when you refresh kicks off the query starts the poll I go back to the site can simply change this to Palm command notification in Qu bec here you refresh oh yeah I forgot any to add one line of code I if you want any code executed when your system is running you need to create some called global application class when the application starts up when you to enable the system to support this
Minute 10

On the new caching one like code it centers a system SQL system data SQL client SQL and SQL dependency start in the name of the connection string in the connection string comes from her configuration manager connection strings in W 2 connection string to now looking at refreshment should work now looks the same here but the traffic going back and forth as can be much simpler in fact there s nothing at the polling going on at this point so once we had our 22nd window you see the refresh and again it s very quiet communication if we do go and change the data in
Minute 11

She shows up right away so we get the benefit of this page invalidation in a table level but it with a lot less traffic going back and forth between systems who don t have the polling going on so he seen with this video the output caching for the whole page it s been around for a while and two techniques enable table level caching the polling mechanism that s working with SQL Server 2000 and 2005 and the new feature for 2005 only which uses the broker service call the command notification try using this technique today to enable better performance for your next web application

No comments: