Wesley Skeen
Wesley Skeen

Reputation: 8285

Asp partial page caching

Is it possible to partially cache a page in asp using output caching?

I am building a blog and each blog post will have its own page I was thinking of caching each blog posts page and using the varybyparam cache parameter on the post id.

The page will have a number of social elements that I want to be different for each person so i don't want these cached.

Upvotes: 0

Views: 1038

Answers (2)

McGarnagle
McGarnagle

Reputation: 102743

If you encapsulate the blog post into a user control, then you can cache it separately.

In control caching, also known as fragment caching, you can cache parts of the page output by creating user controls to contain the cached content and then marking the user controls as cacheable.

So if you set up the blog post as a server control, then you should be able to cache it as normal using VaryByParams.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038720

You could use UserControls for the portions of the page that you want to be cached and use the <%@ OutputCache %> directive to configure it. Here's an article on MSDN which explains the process.

Upvotes: 2

Related Questions