How to cache masterpage settings?
I am using one master page.In that I am registering java scripts and checking some session conditions fo开发者_如何转开发r every page.
I Don't want this one to be called for each and every page.It takes some time to execute the code.
Is there a way to avoid this repetitive execution?
You'll probably have to keep checking the session conditions - as they are per-user, there's no way to guarantee that any one request is coming from the same user without checking sessions/cookies.
As to the script stuff - could you make those declarative (in the mark-up) rather than in the code-behind?
A possible alternative is to look into "donut caching" where you cache most of the page, but leave those areas of the page that change on a "per user" basis out of the cache.
Scott Guthrie has a good post on this:
Tip/Trick: Implement "Donut Caching" with the ASP.NET 2.0 Output Cache Substitution Feature
精彩评论