如何更有效地使用 SiteMap?

发布于 2024-09-01 15:10:09 字数 441 浏览 2 评论 0原文

因此,在我们的网站中,我们使用 SiteMap。对于每个请求,我们都会渲染一些菜单,为此我们在辅助函数中执行 SiteMap.RootNode 操作。

现在,当我使用 dotTrace 对网站进行分析后,我发现 get_RootNode() 花费了大量时间(大约 70-75 毫秒)。但我们知道 SiteMap 是静态的。因此,我想以某种方式在 Application_Start 中仅获取一次 SiteMap.RootNode ,并且在每个请求中都将访问它。

所以,我的问题是,

我的方法正确吗? 我该怎么做呢? 或者有什么有效的方法可以使用 SiteMap.RootNode

谢谢。

So, in our website we are using SiteMap. For each request we render some menu and to do that we do SiteMap.RootNode in the helper function.

Now, when I have done the profiling of my website using dotTrace, I saw the get_RootNode() is taking lot's of time(around 70-75 millisecond). But we know that the SiteMap is static. So, I am thinking in somehow I will get the SiteMap.RootNode only once in Application_Start and will access that through out each request.

So, my questions are,

Is my approach correct?
How should I do that?
Or is there any efficient way that I can use SiteMap.RootNode

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吾性傲以野 2024-09-08 15:10:09

正是出于这个原因,我避免使用站点地图。
它们最多可以包含几百页,但超过这个范围,性能就会开始下降。

我认为它们旨在成为小型网站或其他网站的简单入门工具。

我编写了自己的 cms,理论上,如果您使用类似的 cms / 应用程序以相同的方式构建数据,您应该能够通过获取当前页面 id / 的所有子级,在更短的时间内从数据库中提取菜单列表某种形式的类似基于上下文的查询。

但是,您可以(据我所知)将站点地图分解为较小的部分地图,然后从中提取菜单列表以提高性能。

但是,如果您的网站页面少于 500 个,我会质疑编码……它是自定义站点地图吗?
提供者是否正在等待资源锁或其他什么?

您是否考虑过使用 xmldocument 类来提取数据? (只是一个想法)

I have avoided sitemaps for exactly this reason.
They are ok up to a few hundred pages but beyond that performance will start to degrade.

I think they are meant to be a simple getting started type tool for smaller web sites or something.

I wrote my own cms and in theory if you are using a similar cms / app that structures the data in the same way you should be able to pull your menu listings from the db in less time by getting all children of the current page id / some form of similar context based query.

You can (as i am told) however break down your sitemaps in to smaller partial maps then pull the menu listings from those to increase performance.

If however your site has less than 500 pages I would question the coding ... is it a custom sitemap?
Is the provider waiting for resource locks or something?

Have you considered pulling the data using the xmldocument class instead? (just a thought)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文