jqGrid 减慢 Google 地图速度

发布于 2024-10-20 07:05:27 字数 682 浏览 1 评论 0原文

我正在使用 jqGrid 3.8.2(一个 JavaScript 网格组件)构建一个 ASP.Net MVC 2 应用程序来呈现我存储在数据库中的一些数据。在我的页面上,我还有一个带有平铺覆盖层的 Google 地图。

我注意到此应用程序中地图和图块叠加的加载时间性能比其他不使用 jqGrid 的应用程序中的性能要差得多。如果 jqgrid 和地图同时请求数据,那么速度减慢是很自然的,但是当我缩放/平移地图时,网格没有运行服务器请求。

在我的代码中进行一些调试(一点一点地添加/删除功能)后,我将其归结为:如果我将 jqgrid 配置为使用“datatype : local”,它会将性能恢复到地图!

一旦我设置了“datatype:json”和“url:[myAspNetMvcController]”,地图图块的加载就会受到很大影响。

我的问题是:有谁知道为什么会发生这种情况?看起来 jqGrid 正在后台连续做一些事情,即使它没有被要求获取任何新数据。我在服务器上有断点,所以我知道它不会触发请求。在我看来,一定是 jqgrid 的某种“魔法”导致页面上的其他 javascript 组件运行缓慢,从而导致请求延迟。

对我来说,弄清楚这一点非常重要,我真的不想放弃 jqGrid,因为我真的很喜欢它。

将感谢所有可以为我指明正确方向的反馈!

I am building an ASP.Net MVC 2 application using jqGrid 3.8.2 (a javascript grid component) to present some data I have stored in a DB. On my page I also have a Google map with a tiled overlay.

I have noticed a significant worse performance in loading times of the map and the tile overlay in this application than what I have in other applications that does not use jqGrid. It would be natural with a slow-down if both jqgrid and the map were requesting data at the same time, but when I am zooming/panning the map there are no server requests run by the grid.

After doing some debugging in my code (adding/removing functionality bit by bit) I boiled it down to this: If I configure my jqgrid to use "datatype : local", it brings the performance back in the map!

Once I set "datatype: json" and "url : [myAspNetMvcController]" the loading of the map tiles takes a big hit.

My question is: Does anyone know why this happens? It seems that jqGrid is doing stuff continuously in the background even though it has not been asked to fetch any new data. I have breakpoints on the server, so I know that it does not fire requests. As I see it, it must be some jqgrid "magic" that causes the other javascript components on the page to run slowly, and hence causes the requests to be delayed.

It is very important for me to get to the bottom of this, and I really do not want to have to scrap jqGrid, since I really love it.

Will be thankful for all feedback that can point me in the right direction!

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

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

发布评论

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

评论(1

沧桑㈠ 2024-10-27 07:05:27

找到了答案,原来不是jqgrid那个坏人,而是服务器端的Session存储!我使用 Session 作为网格数据的缓存,因为我需要将过滤后的数据用于网格以外的其他用途,并且希望避免对数据库的冗余访问。一旦我向 Session 对象写入一些内容,服务器就会受到影响并开始以较慢的速度处理所有传入请求(通常是几秒钟!)。后来我了解到,在大多数情况下不建议使用 Session 对象进行缓存,但我仍然不知道为什么它会导致这样的令人讨厌的副作用。如果有人能启发我,那就太好了!这不可能是占用服务器上大量 RAM 的问题,因为仅通过写入就会降低性能

Session["test"] = "test";

由于我实际上需要将数据缓存在会话范围中,所以我通过使用 HttpContext.Cache 和会话解决了这个问题- 特定密钥。

Found the answer, and it turned out not to be jqgrid that was the bad guy, but the server-side Session store! I used Session as a cache for the grid data, because I needed the filtered data for other purposes than the grid, and wanted to avoid redundant trips to the DB. Once I wrote something to the Session object, the server took a hit and started handling all incoming requests slower (often several seconds!). I have later learned that using the Session object for caching is not advised in most cases, but I still don't know why it would cause nasty side-effects like this. If someone would enlighten me, that would be great! It cannot be an issue of taking up alot of RAM on the server, because the performance dropped just by writing

Session["test"] = "test";

Since I actually needed the data to be cached in a session scope, I solved the problem by instead using the HttpContext.Cache and a session-specific key.

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