简体   繁体   English

ASP部分页面缓存

[英]Asp partial page caching

Is it possible to partially cache a page in asp using output caching? 是否可以使用输出缓存在ASP中部分缓存页面?

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. 我正在构建一个博客,并且每个博客帖子都会有自己的页面,我正在考虑缓存每个博客帖子页面,并在帖子ID上使用varbybyparam cache参数。

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. 您可以将UserControls用于要缓存的页面部分,并使用<%@ OutputCache %>指令进行配置。 Here's an article on MSDN which explains the process. 这是有关MSDN文章,它解释了该过程。

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. 因此,如果将博客文章设置为服务器控件,则应该能够使用VaryByParams正常缓存它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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