Php Ajax请求花费的时间太长

Php Ajax请求花费的时间太长,php,jquery,html,ajax,json,Php,Jquery,Html,Ajax,Json,我问你,因为我没有任何想法 我提出了一个ajax请求,从服务器获取一个小数据。json答案已经被服务器缓存了,所以速度非常快 像 但答案时间在大范围内滑动,有时需要1秒有时只有67毫秒 continents.js:65 http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=0&fx_id=6&fx_page=1&

我问你,因为我没有任何想法

我提出了一个ajax请求,从服务器获取一个小数据。json答案已经被服务器缓存了,所以速度非常快

但答案时间在大范围内滑动,有时需要1秒有时只有67毫秒

continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=0&fx_id=6&fx_page=1&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 9
continents.js:102 success: 5087
continents.js:103 complete: 5096
continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=1&fx_id=6&fx_page=2&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 9
continents.js:102 success: 70
continents.js:103 complete: 77
continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=2&fx_id=6&fx_page=3&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 11
continents.js:102 success: 301
continents.js:103 complete: 304
在获得几乎相同大小(以KB为单位)的相同数据结构时。所有内容都由服务器缓存


在服务器端,php的运行时间总是在30-40ms左右。我的错误是什么?

除了您的服务器上的网络速度和性能出现峰值之外,您还可能遇到浏览器中同一主机名的两个活动连接的限制。有几个问题:

  • 您是否有其他可能同时运行的请求
  • 此脚本是否在页面启动时运行?如果是这样的话,它可能会与其他资源请求发生剑战

我建议您查看firebug中的网络面板,查看您的请求发出时还发生了什么。

我在本地运行的Web服务器上遇到了类似的问题。我想它会快得多,但令人惊讶的是,有些网站的性能比它好!也许是服务器速度慢?可能是在您的测试PC上运行的torrent客户端,它会扰乱所有连接(当然我有这个问题:D)浏览器只对同一服务器并行执行有限数量的请求。根据一致请求的数量,这可能会有所不同,因为某些请求在执行之前需要等待。可能您在家中查看页面时,您自己的计算机上的网络速度有波动。100字节输入输出,服务器对我来说是有限的,没有其他人可以访问它。我有120Mbit/80Mbit/s的互联网连接。无论如何,它必须足够快。1)不,我没有。2) 不,它与click绑定。比如:
$(“.pager span”).live(“点击”,function(){if(window.returnedajaxrequest!=window.currentajaxrequest){window.xhr.abort();}if($(this.hasClass(“mod”)&&!($(this.hasClass(“disabled”){if($(this.attr(“rel”)=“f”){window.page=1;showCountries();…等等
continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=0&fx_id=6&fx_page=1&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 9
continents.js:102 success: 5087
continents.js:103 complete: 5096
continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=1&fx_id=6&fx_page=2&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 9
continents.js:102 success: 70
continents.js:103 complete: 77
continents.js:65  http://teszt.domain.com/index.php?fx_action=ajax&fx_mode=continents&fx_type=countries&fx_ajaxid=2&fx_id=6&fx_page=3&fx_pager=9&fx_order=name
continents.js:100 start: 0
continents.js:101 beforesend: 11
continents.js:102 success: 301
continents.js:103 complete: 304