服务器信息:
$ httpd -v
Server version: Apache/2.2.24 (Unix)
Server built: May 8 2013 15:17:37
我使用 openssl 创建了一个自签名 SSL 证书。
测试代码(Java with selenium webdriver):
long startTime, useTime = 0, t;
int count = 10;
for (int i = 0; i < count; i++) {
ChromeDriver driver = new ChromeDriver(capabilities);
startTime = System.nanoTime();
driver.get("https://*.*.*.*/pic.html");
//When testing Http,it will be:driver.get("http://*.*.*.*/pic.html");
//pic.html is a simple page with many images.
t = System.nanoTime() - startTime;
useTime += t;
driver.quit();
}
System.out.println("Average Time: " + useTime/1000000.0/count +" ms");
结果:
HTTPs:Average Time: 1718.13659 ms
HTTP:Average Time: 2484.122677 ms
提前致谢。
最佳答案
使用 https 可能还可以实现内容的透明压缩。压缩和加密(当然还有返回)所增加的时间可能少于通过慢速链接传输较少内容所节省的时间。
您可以通过以下方式验证:
- 使用不可压缩的内容(例如大的 JPEG 图像)
- 显着加快传输链接速度(例如通过使用“localhost”)
关于apache - 为什么在我的 apache 服务器中 https 比 http 更快?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16494481/