问题描述
我是新的phantomjs,尝试它在一个标准的centOS服务器(安装httpd等,但没有修改的设置,除了名称服务器设置为8.8.8.8和8.8.4.4)。
I'm new into phantomjs, trying it on a standard centOS server (with httpd etc installed, but no modified settings apart from nameservers set to 8.8.8.8 and 8.8.4.4).
我使用默认的loadspeed.js文件(可以重命名)。但是,页面速度似乎非常慢。下面是一个示例:
I'm using the default loadspeed.js file (be it renamed). However, page speeds appear to be extremely slow. Here's an example:
$ 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(例如),loadtime为141msec:
When I load any url on the server (such as http://something.be ), loadtime is 141msec:
$ phantomjs phantomjs.js http://something.be
starting
Loading time 141 msec
一个线索是什么原因导致我的连接是这么慢?连接本身很好,wget需要几秒钟才能下载几MB的文件。
Does anyone have a clue what causes my connection to be this slow? The connection itself is fine, wget takes seconds to download a file of several MB.
此外,当我在Google本地为OSX运行完全相同的脚本时,输出:
Also, when I run the exact same script on OSX locally for Google, this is the output:
phantomjs phantomjs.js http://google.com/
starting
Loading time 430 msec
推荐答案
发现 - 似乎ipv6是罪魁祸首。
Found it - seems like ipv6 was the culprit.
我通过运行以下操作暂时禁用它:
I disabled it temporarily by running the following:
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
测试确认:
Testing confirms:
$ phantomjs phantomjs.js http://google.com
starting
Loading time 230 msec
这篇关于Phantomjs缓慢加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!