减少页面加载时间mvc3 [英] Reduce page load time mvc3

查看:84
本文介绍了减少页面加载时间mvc3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站正在使用从db.Ajax加载的顶级菜单。我注意到我的页面加载速度很慢(超过6秒)。我使用的是asp.net mvc3和sql server 2008r2。任何想法?

My website is using top menu loaded from db.Ajax. I noticed that my page is loading slow (over 6 sec). I am using asp.net mvc3 and sql server 2008r2. Any ideas ?

推荐答案

斯蒂芬·休伊森的回答只是一些补充:



  • 在第一次运行时,代码及时编译为本机代码,这需要时间。在开发过程中经常发生这种情况
  • 部署时,唤醒apppool的时间也需要时间
  • IE正在执行比Chrome更多的javascript处理同步,因此你应该检查不同的浏览器看
  • 您可以使用Fiddler,IE9 +开发工具栏(和其他工具)来分析DOM操作以及网络活动。因此,您可以了解延迟的哪一方。
  • De开发环境的性能与生产服务器的性能相同。因此,服务器端执行时间将高度依赖于下面的基础架构
  • 您可能需要查询优化和/或索引优化
  • 许多事情取决于您使用的数据访问技术。 EF通常很快,但您可以直接使用LinqPad进行检查。
  • 如果您将数据作为json获得,并且您一次获得大量数据,则json解析和DOM操作可能需要相当长的时间,您可以尝试优化一次获取的数据量
  • 您可以通过在head部分中获取数据来尽快欺骗客户端进行ajax调用,但仅在DOM之后显示它准备好了。
Just some additions to Stephen Hewison's answer:

  • At first run the code is "just in time" compiled to native code, this takes time. During development this happens often
  • When deployed, the time to wake up an apppool takes also time
  • IE is doing more synchronously the javascript processing than chrome for example, thus you should check with different browsers to see
  • You can use Fiddler, IE9+ development toolbar (and other tools) to profile not only DOM manipulation but also network activity. Thus you could get an idea on which side the latency is.
  • De development environment has rarely the same performance than a production server. So server side execution time will highly depend on the infrastructure beneath
  • You might need query optimization and/or index optimization
  • Many things depend on the data access technology you use. EF is fast in general, but you could check it directly with LinqPad for example.
  • If you get your data as json, and you get much data at once, json parsing and DOM manipulation can take considerable time, you can try to optimize how many data you fetch at once
  • You can trick the client side to do the ajax call as soon as possible by fetching data in the head section, but displaying it only after the DOM is ready.


没有通过我认为在论坛上不合适的所有代码。



没有办法直接回答这个问题。



但是......告诉你如何找到答案会更容易。



性能分析是你的朋友。使用分析工具我最近将应用程序的加载时间缩短了50%。



如果您有Visual Studio Premium或Ultimate版本,则可以访问Analyze菜单。这包括一些工具,它们将向您显示执行代码的每一部分所花费的时间。



如果不这样做,您可以下载评估版Ants来自RedGate的Profiler。但是如果你发现它有用,请购买它。



通常延迟也是SQL查询速度慢的结果。使用SQL管理工作室,您可以查看任何给定SQL查询的执行计划。



执行计划将向您显示正在执行的操作以生成结果。查找每种操作类型,找出哪些是好的,哪些是后面的以及如何改进它们。
Without going through all your code, which I don't think would be appropriate on a forum.

There's no way to answer that directly.

But... Telling you how to find the answer is a bit easier.

Profiling is your friend. Using profiling tools I recently slashed the load times for an application by 50%.

If you have Visual Studio Premium or Ultimate editions you have access to the Analyze menu. This includes a number of tools which will show you the amount of time spent executing each bit of your code.

If you don't you can download the evaluation version Ants Profiler from RedGate. But please buy it if you find it useful.

Often delays are also a result of slow SQL queries. Using SQL management studio you can look the execution plan for any given SQL query.

The execution plan will show you the operations being execute to generate the results. Look up each operation type and find out which ones are good, which ones are back and how to improve them.


这篇关于减少页面加载时间mvc3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆