简体   繁体   中英

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM