简体   繁体   English

移动 Safari (iPhone) 有 30 秒 + Javascript GET 请求的延迟

[英]Mobile Safari (iPhone) has 30 sec + latency for Javascript GET requests

I am developing a mobile web application: www.bazmo.com.我正在开发一个移动网络应用程序:www.bazmo.com。 When I test the site, the latency of the GET JS requests can get up to 30 seconds.当我测试站点时,GET JS 请求的延迟可能会达到 30 秒。 It basically seems broken to the user.它基本上对用户来说似乎是坏的。

Here is how I recreate the error:这是我重新创建错误的方法:

  • Turn off cellular (wifi only)关闭蜂窝网络(仅限 wifi)
  • Clear History and Website Data清除历史记录和网站数据
  • Open safari and go to a page like www.bazmo.com/best/laptops打开 safari 并转到类似 www.bazmo.com/best/laptops 的页面
  • Then click on the logo to go to the home page at which point it gets stuck for 30 seconds before the JS files load if they are not cached然后点击logo进入首页,如果没有缓存,JS文件加载前会卡住30秒

I sometimes can catch it on Web Inspector and it just shows the JS not being loaded for 30 seconds.有时我可以在 Web Inspector 上捕获它,它只显示 JS 未加载 30 秒。

What am I missing here.我在这里错过了什么。

I just use simple: to insert the files in.我只是使用简单的:插入文件。

I found a work around but not a permanent solution.我找到了解决方法,但不是永久解决方案。 The website uses Google App Engine.该网站使用 Google App Engine。

The line:线路:

script src="/javascript/categoryScript.js"> just did not work on safari mobile. script src="/javascript/categoryScript.js"> 在 safari mobile 上不起作用。

However the line:然而这一行:

script src="yourid.appspot.com/javascript/categoryScript.js"> does since it is trying to retrieve from another domain.脚本 src="yourid.appspot.com/javascript/categoryScript.js"> 这样做是因为它试图从另一个域中检索。

This helps provide a workaround but it is pretty bad form that I can't use the path from the domain itself.这有助于提供一种解决方法,但我无法使用域本身的路径是非常糟糕的形式。

I have been trying to find a way to make that work but no dice so far.我一直试图找到一种方法来使这项工作发挥作用,但到目前为止还没有骰子。

We had the same issue and problem was that our back-end returned 204 status and not 200 .我们遇到了同样的问题,问题是我们的后端返回204状态而不是200 BUT this issue was caused by using HTTP OPTIONS method and not GET (but it can be caused by the same thing).但是这个问题是由使用HTTP OPTIONS方法而不是GET引起的(但它可能是由同一件事引起的)。

Related reading:相关阅读:

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

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