• <small id='yZwWr'></small><noframes id='yZwWr'>

        <legend id='yZwWr'><style id='yZwWr'><dir id='yZwWr'><q id='yZwWr'></q></dir></style></legend>
          <bdo id='yZwWr'></bdo><ul id='yZwWr'></ul>
        <i id='yZwWr'><tr id='yZwWr'><dt id='yZwWr'><q id='yZwWr'><span id='yZwWr'><b id='yZwWr'><form id='yZwWr'><ins id='yZwWr'></ins><ul id='yZwWr'></ul><sub id='yZwWr'></sub></form><legend id='yZwWr'></legend><bdo id='yZwWr'><pre id='yZwWr'><center id='yZwWr'></center></pre></bdo></b><th id='yZwWr'></th></span></q></dt></tr></i><div id='yZwWr'><tfoot id='yZwWr'></tfoot><dl id='yZwWr'><fieldset id='yZwWr'></fieldset></dl></div>
        <tfoot id='yZwWr'></tfoot>
      1. Service Worker 可以响应同步的 XHR 请求吗?

        Can Service Workers respond to synchronous XHR requests?(Service Worker 可以响应同步的 XHR 请求吗?)
        • <tfoot id='2Kf4D'></tfoot>
            <tbody id='2Kf4D'></tbody>
          • <small id='2Kf4D'></small><noframes id='2Kf4D'>

            • <bdo id='2Kf4D'></bdo><ul id='2Kf4D'></ul>
              1. <legend id='2Kf4D'><style id='2Kf4D'><dir id='2Kf4D'><q id='2Kf4D'></q></dir></style></legend>

                  <i id='2Kf4D'><tr id='2Kf4D'><dt id='2Kf4D'><q id='2Kf4D'><span id='2Kf4D'><b id='2Kf4D'><form id='2Kf4D'><ins id='2Kf4D'></ins><ul id='2Kf4D'></ul><sub id='2Kf4D'></sub></form><legend id='2Kf4D'></legend><bdo id='2Kf4D'><pre id='2Kf4D'><center id='2Kf4D'></center></pre></bdo></b><th id='2Kf4D'></th></span></q></dt></tr></i><div id='2Kf4D'><tfoot id='2Kf4D'></tfoot><dl id='2Kf4D'><fieldset id='2Kf4D'></fieldset></dl></div>
                  本文介绍了Service Worker 可以响应同步的 XHR 请求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想使用 Service Worker 来增强现有网站.特别是,我想通过让 Service Worker 在实际资源不可用时使用占位符资源响应请求来添加更好的离线支持.这种方法一直有效,但我遇到了障碍.站点中有几个地方使用 同步 XHR 请求来加载某些资源,而我的 Service Worker 在 Chrome 中没有接收到它们的事件.(请不要建议消除同步 XHR 请求.这是可取的,但超出了范围.)

                  I would like to use Service Workers to enhance an existing web site. In particular, I would like to add better offline support by having Service Workers respond to requests with placeholder resources when the actual resources are not available. This approach had been working, but I've encountered an obstacle. There are a few places in the site where synchronous XHR requests are used to load certain resources, and my Service Worker doesn't receive events for them in Chrome. (Please don't suggest eliminating synchronous XHR requests. That's desired, but out-of-scope.)

                  Service Worker 是否可以响应同步 XHR 请求?我可以想象这实现起来很复杂,如果不支持它会理解的.W3C 服务工作者规范(工作草案) 和WHATWG Fetch Specification (Living Standard),但我还没有完成破译.我希望能解释一下规范如何描述是否应支持这一点,和/或对有关指定或实施此行为的讨论的任何引用.

                  Is it supposed to be possible for a Service Worker to respond to synchronous XHR requests? I could imagine this being complicated to implement, and would understand if it wasn't supported. A "correct" answer should exist between the W3C Service Workers Specification (Working Draft) and the WHATWG Fetch Specification (Living Standard), but I haven't finished deciphering them. I would appreciate an explanation of how the specifications describe whether or not this should be supported, and/or any references to discussions about specifying or implementing this behaviour.

                  推荐答案

                  理论上

                  是的,Service Worker 应该能够响应同步 XHR 请求.这在规范中没有明确说明,但是没有例外会导致同步 XHR 请求被区别对待,并且 W3C Web 平台测试 (WPT) 套件有一个测试用例来验证它是否受支持:wpt/service-workers/service-worker/fetch-request-xhr-sync.https.html.

                  从 2019 年 1 月起,Service Worker 可以在 Firefox 和 Edge 中响应同步 XHR 请求,但不能在 Chrome 或 Safari 中响应.Chrome 计划很快添加支持,但我们不知道 Safari 是否会这样做.

                  As of January 2019, service workers can respond to synchronous XHR requests in Firefox and Edge, but not in Chrome or Safari. Chrome is planning to add support soon, but we don't know if Safari ever will.

                  提供最新的浏览器支持矩阵 在 WPT.fyi.您可以在自己的浏览器中运行 WPT 测试用例 https://w3c-test.org/service-workers/service-worker/fetch-request-xhr-sync.https.html.

                  An up-to-date browser support matrix is available at WPT.fyi. You can run the WPT test case in your own browser at https://w3c-test.org/service-workers/service-worker/fetch-request-xhr-sync.https.html.

                  这篇关于Service Worker 可以响应同步的 XHR 请求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SCRIPT5: Access is denied in IE9 on xmlhttprequest(SCRIPT5:在 IE9 中对 xmlhttprequest 的访问被拒绝)
                  XMLHttpRequest module not defined/found(XMLHttpRequest 模块未定义/未找到)
                  Show a progress bar for downloading files using XHR2/AJAX(显示使用 XHR2/AJAX 下载文件的进度条)
                  How can I open a JSON file in JavaScript without jQuery?(如何在没有 jQuery 的情况下在 JavaScript 中打开 JSON 文件?)
                  How do I get the HTTP status code with jQuery?(如何使用 jQuery 获取 HTTP 状态码?)
                  quot;Origin null is not allowed by Access-Control-Allow-Originquot; in Chrome. Why?(“Access-Control-Allow-Origin 不允许 Origin null在铬.为什么?)

                    <tbody id='QxH2t'></tbody>
                  <legend id='QxH2t'><style id='QxH2t'><dir id='QxH2t'><q id='QxH2t'></q></dir></style></legend>
                      <tfoot id='QxH2t'></tfoot>

                      <i id='QxH2t'><tr id='QxH2t'><dt id='QxH2t'><q id='QxH2t'><span id='QxH2t'><b id='QxH2t'><form id='QxH2t'><ins id='QxH2t'></ins><ul id='QxH2t'></ul><sub id='QxH2t'></sub></form><legend id='QxH2t'></legend><bdo id='QxH2t'><pre id='QxH2t'><center id='QxH2t'></center></pre></bdo></b><th id='QxH2t'></th></span></q></dt></tr></i><div id='QxH2t'><tfoot id='QxH2t'></tfoot><dl id='QxH2t'><fieldset id='QxH2t'></fieldset></dl></div>

                      <small id='QxH2t'></small><noframes id='QxH2t'>

                        <bdo id='QxH2t'></bdo><ul id='QxH2t'></ul>