NibblyPig
NibblyPig

Reputation: 52932

Is it possible to cache an asp page on the server side?

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?

Upvotes: 3

Views: 112

Answers (2)

Joe Ratzer
Joe Ratzer

Reputation: 18549

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

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.

Upvotes: 4

MatthewMartin
MatthewMartin

Reputation: 33143

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

Upvotes: 1

Related Questions