Reading the @OutputCache documentation in MSDN I have noticed the Shared
attribute
Doc says:
Shared
A Boolean value that determines whether user control output can be
shared with multiple pages. The default is false. For more information, see the Remarks section.
Remarks says:
If you set the Shared attribute to true, cached user control output can be accessed by multiple Web Forms pages. If you do not set it to true, the default behavior is to cache one version of user control output for each page that contains that user control. You can potentially save a significant amount of memory by enabling the Shared attribute. For more information, see Caching Portions of an ASP.NET Page.
So I'm starting to believe that normally this should be set to true for controls that are gonna be rendered exactly in different pages in order to save cache memory.
The question is... when should I not set Shared
to true?
You should not use it when the control output is different across different pages.
Say you have a control whose output changes depending on how one navigates your site (breadcrumb control) - you do not want that to be shared across pages.