apache - 为什么在我的 apache 服务器中 https 比 http 更快?

标签 apache http ssl https page-load-time

服务器信息:

$ 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/

相关文章:

http - IIS 6.0 上的设置错误代码

http - 将图像请求路由到单独的子域

ruby-on-rails - 配置 WEBrick 以使用自动生成的自签名 SSL/HTTPS 证书

android - Ionic Android 应用程序在签名版本 apk 上没有互联网访问权限,但调试工作正常

重新定义默认 SSL 上下文时找不到 Java keystore

windows - 找不到用于 apache/windows 的 mod_wsgi

PHP - 找不到 fatal error 类

apache - 重写规则(静态内容除外)

angular - 组件中的变量仅在 Angular 4 服务中的第二次函数调用后才会更新

c - 在 Ansi C 中解析 A​​pache 日志