简体   繁体   English

iPad上的MVC 4网站速度很慢

[英]MVC 4 website very slow on iPad

I have developed a point of sale system using MVC 4.The responsiveness and loading times on Windows and Mac is instant but on an iPad it takes 8-13 seconds to load a page or perform an action such as adding items to basket. 我已经开发了一个使用MVC 4的销售点系统。在Windows和Mac上的响应速度和加载时间是即时的,但在iPad上加载页面或执行诸如向篮子添加项目等操作需要8-13秒。 To improve the speed of the web application I enabled compression in IIS and minified all my java script files I also used bundling to bundle the following .js files together which supposedly improves loading of pages as well: 为了提高Web应用程序的速度,我在IIS中启用了压缩并缩小了我的所有java脚本文件,我还使用捆绑将以下.js文件捆绑在一起,这可能会改善页面的加载:

  1. jquery-1.8.2.min.js jQuery的1.8.2.min.js
  2. knockout-2.2.0.js 淘汰赛2.2.0.js
  3. jquery.easing.1.3.js jquery.easing.1.3.js
  4. b.popup.min.js(used for displaying a modal popup only 6KB) b.popup.min.js(用于显示模式弹出窗口仅6KB)

The other javascript files I use on pages are between 5KB and 15KB.After doing all this the application seems to be a few seconds quicker, but still takes unacceptably long(8-10 seconds). 我在页面上使用的其他javascript文件介于5KB和15KB之间。完成所有这些后,应用程序似乎要快几秒,但仍然需要很长时间(8-10秒)。

Has anyone experienced similar performance issues on an iPad and how did you resolve it?Is there anything else I can do to improve performance? 有没有人在iPad上遇到类似的性能问题,你是如何解决它的?我还能做些什么来提高性能吗?

I'm using Windows Server 2003 and IIS 6.0 我正在使用Windows Server 2003和IIS 6.0

Here's my bundle registration code: 这是我的包注册码:

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Scripts/jquery-1.8.2.min.js",
        "~/Scripts/jquery.easing.1.3.js",
        "~/Scripts/knockout-2.2.0.js",
        "~/Scripts/common/common.min.js",
        "~/Scripts/popup.min.js"
        ));

    bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));
    BundleTable.EnableOptimizations = true;
}

And this is where I call it on the master page: 这就是我在母版页上调用它的地方:

@using System.Configuration
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <title>Prestige SSC</title>
    @Scripts.Render("~/bundles/jquery")
    @RenderSection("scripts", required: false)
    @Styles.Render("~/Content/css")   
    <script type="text/javascript">
        var screenRefreshTime = '@ConfigurationManager.AppSettings["ScreenRefreshTime"].ToString()';
        screenRefreshTime = parseInt(screenRefreshTime);
    </script>
</head>
<body>
    @RenderBody()
</body>
</html>

When it comes to web site performance, it can be millions of things. 谈到网站性能,它可能是数以百万计的事情。 It's not necessary the JavaScript files that causing the problem. 导致问题的JavaScript文件不是必需的。 Here's few things that might help you: 以下几点可能对您有所帮助:

  1. Connect your iPad to Mac / PC and enable Safari web inspector tools. 将iPad连接到Mac / PC并启用Safari Web检查器工具。 With Web Inspector Tools, you can see what process is taking longest time. 使用Web Inspector Tools,您可以查看哪个进程花费的时间最长。 See this: https://developer.apple.com/library/iad/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html 请参阅: https//developer.apple.com/library/iad/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html
  2. Go through the list of possible fixes from this free ebook: http://www.red-gate.com/products/dotnet-development/ants-performance-profiler/entrypage/avoid-find-fix-asp-problems 查看此免费电子书中可能修复的列表: http//www.red-gate.com/products/dotnet-development/ants-performance-profiler/entrypage/avoid-find-fix-asp-problems
  3. Try to run from Chrome in iPad. 尝试从iPad中的Chrome运行。 Chrome is known to have the fastest JavaScript engine. 众所周知,Chrome拥有最快的JavaScript引擎。 Also, try remote debugging your iPad's Chrome. 另外,尝试远程调试iPad的Chrome。 Chrome's developer tools has JavaScript Profiler to check what specific code / function that lags. Chrome的开发者工具具有JavaScript Profiler,可以检查落后的具体代码/功能。 See: http://blog.prototest.com/guide-to-remote-debugging-ios-and-android-mobile-devices . 请参阅: http//blog.prototest.com/guide-to-remote-debugging-ios-and-android-mobile-devices
  4. You can also remote debug to Android-based tablet. 您还可以远程调试到基于Android的平板电脑。 If the same thing happens on Android tablet, use PC Chrome to remote debug your mobile device. 如果在Android平板电脑上发生同样的事情,请使用PC Chrome远程调试移动设备。
  5. Does your network blocking traffic for certain devices? 您的网络是否会阻止某些设备的流量?
  6. Optimize your Knockout code. 优化您的Knockout代码。 Knockout is great, but you can overdo with its automatic UI refresh and dependency tracking. Knockout很棒,但你可以通过自动UI刷新和依赖性跟踪来过度使用。
  7. Optimize your JavaScript code. 优化您的JavaScript代码。 Run your code through jshint.com or jslint.com 通过jshint.com或jslint.com运行您的代码

for iPads (and also any other device / platform that has a browser which is not IE 8 or less) jQuery 2 perform way better.. it is actually jQuery that weight a lot and in older versions it carries on lots of unrelevant validations and backward compatibility stuff 对于iPad(以及任何其他设备/平台,其浏览器不是IE 8或更低)jQuery 2执行方式更好..它实际上是jQuery的重量很多,在旧版本中它进行了大量不相关的验证和落后兼容性东西

so, you can try to: 所以,你可以尝试:

  1. replace that version of jQuery 替换那个版本的jQuery
  2. split your jQuery include command from the rest and use an if statement to determine if you need an older or newer version of jQuery 从其余部分拆分jQuery include命令并使用if语句确定是否需要更新版本的jQuery

in short (based on this post Detect Internet explorer browser version problems ) 总之(基于这篇帖子检测Internet Explorer浏览器版本问题

var jQuery = "~/Scripts/jquery-2.1.1.min.js";

if ((Request.Browser.Browser == "IE") && ((Request.Browser.MajorVersion < 9)))
{
    jQuery = "~/Scripts/jquery-1.8.2.min.js";
}

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    jQuery,
    "~/Scripts/jquery.easing.1.3.js",
    "~/Scripts/knockout-2.2.0.js",
    "~/Scripts/common/common.min.js",
    "~/Scripts/popup.min.js"
    ));

Try downloading wireshark to the server, start it up, and recreate the error while capturing the packet flow. 尝试将wireshark下载到服务器,启动它,并在捕获数据包流时重新创建错误。 Then find the packets for that application right click and choose "Follow TCP Stream". 然后右键单击该应用程序的数据包并选择“Follow TCP Stream”。 You'll be able to see and filter just those packets out. 您将能够看到并过滤掉这些数据包。

You want to look for inbound requests and outbound responses with respect to how long it took for the server to respond. 您希望查找有关服务器响应时间的入站请求和出站响应。 If the times are fast <100ms then you have to next look to see how long each subsequent request from the IPAD is taking. 如果时间快<100ms,那么接下来你必须看看来自IPAD的每个后续请求需要多长时间。 You should be able to spot where the dealays easily just by looking at the relative time column in the trace. 通过查看跟踪中的相对时间列,您应该能够轻松找到dealays的位置。

From there if this is a pure client issue you'll need to focus on the device side. 从那里,如果这是一个纯客户端问题,你需要专注于设备方面。 If it's a network thing, then you'll at least be able to rule out the application. 如果它是网络的东西,那么你至少可以排除应用程序。 If it's an application issue, then you'll be able to see what needs to be corrected. 如果这是一个应用程序问题,那么您将能够看到需要纠正的内容。

Keep in mind that no application can run from a client until all the network things are ready, for example there must be a DNS resolve before any packets can fly. 请记住,在所有网络都准备就绪之前,任何应用程序都无法从客户端运行,例如,在任何数据包可以飞行之前必须有DNS解析。 You may also note that one or more duplicate packets are being sent.. This is usually an indicator of improper bridging and or router issues. 您可能还注意到正在发送一个或多个重复的数据包。这通常是不正确的桥接和/或路由器问题的指示。 There may also be what is known as a Hop count issue, whereby delays are being caused by the number of routers the device has to hit. 还可能存在所谓的跳数问题,其中延迟是由设备必须达到的路由器的数量引起的。 There could also be a router "Breathing" issue whereby the router's traffic is overwhelming it (which the architecture says "just throw the packets away"). 还可能存在路由器“呼吸”问题,其中路由器的流量是压倒性的(架构称“只是丢弃数据包”)。 When this happens TCP attempts to retry, which in essence makes things worse. 当发生这种情况时,TCP会尝试重试,这实际上会使事情变得更糟。

Check your server network activity using Wireshark https://www.wireshark.org 使用Wireshark https://www.wireshark.org检查您的服务器网络活动

I've had the problem where the server was trying to connect to the client using netbios and ICMP to resolve the clients details and that was timing out. 我遇到了服务器尝试使用netbios和ICMP连接到客户端以解决客户端详细信息并且超时的问题。

Disable the Netbios over TCP on the server and check then to see if it's a networking issue and not actually a programming issue. 在服务器上禁用TCP上的Netbios,然后检查它是否是网络问题,而不是实际的编程问题。

  1. Go to control panel and select Network Connections. 转到控制面板,然后选择“网络连接”。
  2. Right-click the local area connection that you want to be statically configured, and then click Properties. 右键单击要静态配置的本地连接,然后单击“属性”。
  3. Click Internet Protocol (TCP/IP), click Properties, click Advanced, and then click the WINS tab. 单击“Internet协议(TCP / IP)”,单击“属性”,单击“高级”,然后单击“WINS”选项卡。
  4. Click Disable NetBIOS over TCP/IP. 单击“禁用TCP / IP上的NetBIOS”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM