Caching a user control in ASP.NET?

后端 未结 4 433
鱼传尺愫
鱼传尺愫 2021-01-18 02:43

I have created a user control in my application \"header.ascx\", I am pasing a selectedMenu attribute to this control on which the control selects the selectedMenu value spe

4条回答
  •  無奈伤痛
    2021-01-18 03:10

    I don't think it's a good idea to cache the control itself:

    • When the control is created the very first time, it has references to its parent page among others.
    • When you retrieve the control from the cache, those references does no longer exists.

    A better approach, I think, is to cache the data which the control is using instead. ASP.NET creates so many controls during the page life cycle, that caching this one control really doesn't improve anything.

    Then a stupid question at the end: Is this control a bottleneck? Do you really need the cache?

提交回复
热议问题