【问题标题】:Is there a way to decrease request download time for requirejs with Apache Tomcat 9.0.48 +?有没有办法使用 Apache Tomcat 9.0.48 + 减少 requirejs 的请求下载时间?
【发布时间】:2021-07-28 20:43:56
【问题描述】:

我有一个通过在 Apache Tomcat 服务器 (9.0.48) 上运行的 requirejs 加载模块的应用程序。从 tomcat 9.0.46 升级到 9.0.48 时,我注意到页面加载不一致并出现错误 Load timeout for modules: ...

当模块加载失败时,较大模块(jquery、wysihtml5)的内容下载时间从约 100 毫秒变为 1 分钟。总体而言,整个页面加载时间从约 500 毫秒增加到约 600 毫秒。我没有观察到使用来自 tomcat 9.0.46 的 tomcat-coyote 的下载时间大于 200 毫秒;似乎这是 9.0.48 tomcat-coyote lib 的新功能。

有没有办法加快模块下载时间?

配置

requirejs 配置

requirejs 作为数据主加载: <script type="text/javascript" src="/configurator/assets/js/lib/utils/require-2.3.6.min.js" data-main="/configurator/assets/js/main"></script>

requirejs.config({
  "paths" : {
    "jquery" : "lib/jquery/jquery-1.8.3",
    "jquery-ui" : "lib/jquery/jquery-ui-1.10.3.custom.min",
    "fileupload" : "lib/jquery/jquery.fileupload",
    "jquery.iframe" : "lib/jquery/jquery.iframe-transport",
    "jquery.ui.widget" : "lib/jquery/jquery.ui.widget",
    "jquery.ba-hashchange" : "lib/jquery/jquery.ba-hashchange",
    "underscore" : "lib/utils/lodash-1.0.0-rc3.min",
    "wysihtml5" : "lib/xing-wysihtml5/wysihtml5-0.3.0",
    "wysihtml5_parserrules" : "lib/xing-wysihtml5/advanced",
    "bootstrap" : "lib/bootstrap/bootstrap-2.1.0.min",
    "can" : "lib/can/can",
    "configurator" : "app/configurator",
  },
  "shim" : {
    "jquery": {
      "deps" : [ ],
      "exports" : "jQuery"
    }
    "underscore" : {
      "deps" : [ ],
      "exports" : "_"
    },
    "less" : {
      "deps" : [ ],
      "exports" : "less"
    },
    "fileupload" : {
      "deps" : [ "jquery" ],
      "exports" : "fileupload"
    },
    "bootstrap" : {
      "deps" : [ "jquery-ui" ],
      "exports" : "bootstrap"
    },
    "jquery-ui" : {
      "deps" : [ "jquery" ],
      "exports" : "jquery-ui"
    },
    "jquery.iframe" : {
      "deps" : [ "jquery" ],
      "exports" : "jquery.iframe"
    },
    "jquery.ui.widget" : {
      "deps" : [ "jquery" ],
      "exports" : "jquery.ui.widget"
    }
  },
  "modules" : [ {
    "name" : "main"
  } ],
  "appDir" : ".",
  "baseUrl" : "../../../configurator/assets/js",
  "waitSeconds": "0"
});

require([
    'jquery',
    'can',
    'underscore',
    'configurator',
    'bootstrap'

], function($, can, _, Configurator) {
   ...
   });
});

Tomcat 连接器配置

<Connector port="8443" address="0.0.0.0" SSLEnabled="true"
               maxHttpHeaderSize="8192" emptySessionPath="false"
               maxKeepAliveRequests="-1"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLSv1.2"  sslEnabledProtocols="TLSv1.2"
               keystoreFile="..." keystorePass="..." keystoreType="..."
               useBodyEncodingForURI="true" URIEncoding="UTF-8"
               ciphers="..." />

【问题讨论】:

  • 你能在浏览器开发工具网络面板中看到缓慢的请求吗?
  • 我可以!内容下载在恰好 1 分钟后完成,不一致;下载时间长的模块本身也很大(> 100KB)。 wysihtml5 模块的示例:Queueing: 4.35ms Stalled: 1.91 ms Request sent: 0.27ms Waiting (TTFB): 17.96ms Content Downloaded: 1.0min 通常该模块的内容下载时间约为 100 毫秒。

标签: requirejs tomcat9


【解决方案1】:

这个问题似乎在 Tomcat 9.0.52 中得到修复。相关错误:https://bz.apache.org/bugzilla/show_bug.cgi?id=65448

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多