如何缓存母版页设置?
我正在使用一个母版页。我正在注册 java 脚本并检查每个页面的一些会话条件。
我不希望每个页面都调用这个。执行代码需要一些时间。
有没有办法避免这种重复执行呢?
I am using one master page.In that I am registering java scripts and checking some session conditions for 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能必须不断检查会话条件 - 因为它们是针对每个用户的,所以如果不检查会话/cookie,就无法保证任何一个请求都来自同一用户。
至于脚本的东西 - 你可以让这些声明(在标记中)而不是在代码隐藏中吗?
一种可能的替代方法是研究“甜甜圈缓存”,其中缓存了大部分页面,但将基于“每个用户”更改的页面区域保留在缓存之外。
Scott Guthrie 在这方面有一篇很好的文章:
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: