views:

38

answers:

2

Let's assume you have a big complex index page, that shows news articles and stuff. It's not going to change very often. Can you cache it somehow on the serverside, so requests don't force to server to dynamically generate the entire page every time someone visits it? Or does ASP.NET do this automatically?

If so, how does it know if something has changed?

+1  A: 

Yes, caching exists, MSDN discusses it better than I can here. http://msdn.microsoft.com/en-us/library/06bh14hk.aspx

MatthewMartin
+4  A: 

Yes you can, here is the declarative version of page caching, which will cache the page for 60 seconds:

<%@ OutputCache Duration="60" VaryByParam="None" %>

You ask about changes, notice the VaryByParam part - you can, for example, ensure that there is one cached page for each parameter. You can even implement your own custom variation with VaryByCuston, which can be really powerful:

VaryByCustom

Any text that represents custom output caching requirements. If this attribute is given a value of browser, the cache is varied by browser name and major version information. If a custom string is entered, you must override the HttpApplication.GetVaryByCustomString method in your application's Global.asax file.

Joe R
Oh sweet, this is very interesting! Thanks.
SLC