开发者

In ASP.NET, .NET3.5 and IIS7 caching commonly used controls so IIS don't have to rebuild them on a each page request?

In ASP.NET, .NET3.5 and IIS7, can you cache commonly used controls so you don't have to rebuild them开发者_高级运维 on a each page load?

I have an asp control, in this case a telerik treeview control, but this question is for asp controls in general. I'm simply going to use my treeview to illustrate what I'm looking for.

I'm building a telerik treeview control that is populated with data from a (expensive) query to my database. I was thinking, I could cache the results of the query in a table and have a scheduled sproc run every 15 minutes and update this caching table.

Then I figured the built control will not change either, so is there any way, using IIS to keep a version of a built control so I can eliminate all the code behind logic needed to assemble it. Afterall, it is the same everytime. I could save bandwith between IIS and SQL as well as CPU cycles.


If you make your treeview into a usercontrol, you can use the "OutputCache" directive to cache its contents: http://msdn.microsoft.com/en-us/library/h30h475z(VS.90).aspx


"can you cache commonly used controls so you don't have to rebuild them on a each page load?". Yes, you can http://msdn.microsoft.com/en-us/library/h30h475z.aspx.

For sql you can use http://msdn.microsoft.com/en-us/library/system.web.caching.sqlcachedependency.aspx


You can wrap the Server Control in a User control and define the OutputCache directive with the Property Shared Set to True and Duration Set to 900. i.e:

<%@ OutputCache Duration=900 Shared=True ...

Check this link for more Information:

Output Cache

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜