我是phantomjs的新手,可以在标准centOS服务器上进行尝试(安装了httpd等,但是除了将名称服务器设置为8.8.8.8和8.8.4.4之外,没有其他修改过的设置)。
我正在使用默认的loadspeed.js文件(已重命名)。但是,页面速度似乎非常慢。这是一个例子:
$ phantomjs phantomjs.js http://www.google.com/
starting
Loading time 90928 msec
$ phantomjs phantomjs.js http://173.194.67.138/ #(one of google's public ips)
starting
Loading time 30204 msec
当我在服务器上加载任何URL(例如http://something.be)时,加载时间为141毫秒:
$ phantomjs phantomjs.js http://something.be
starting
Loading time 141 msec
有人知道导致我的连接如此缓慢的原因吗?连接本身很好,wget只需几秒钟即可下载数MB的文件。
另外,当我在本地的OSX上为Google运行完全相同的脚本时,这是输出:
phantomjs phantomjs.js http://google.com/
starting
Loading time 430 msec
最佳答案
找到了-似乎是ipv6的罪魁祸首。
我通过运行以下命令暂时禁用了它:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
测试确认:
$ phantomjs phantomjs.js http://google.com
starting
Loading time 230 msec
关于connection - Phantomjs缓慢加载页面,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15684185/