<bdo id='1Ucse'></bdo><ul id='1Ucse'></ul>

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

      <small id='1Ucse'></small><noframes id='1Ucse'>

      <legend id='1Ucse'><style id='1Ucse'><dir id='1Ucse'><q id='1Ucse'></q></dir></style></legend>

        如何检测 XHR 何时返回缓存的资源?

        How to detect when XHR returns a cached resource?(如何检测 XHR 何时返回缓存的资源?)
          <legend id='THOp6'><style id='THOp6'><dir id='THOp6'><q id='THOp6'></q></dir></style></legend>

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

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

          • <bdo id='THOp6'></bdo><ul id='THOp6'></ul>
          • <tfoot id='THOp6'></tfoot>
              <tbody id='THOp6'></tbody>

                1. 本文介绍了如何检测 XHR 何时返回缓存的资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我想知道是否有一种方法可以检测何时从本地缓存返回响应?是否可以?

                  I'm wondering if there is a way how to detect when a response is returned from a local cache? Is it possible?

                  解决方案应该是通用的并且适用于无条件请求.在这种情况下,响应代码总是 200 OK,但是 XHR 为第二个请求返回一个缓存的资源(例如,第一个响应包含 Expires 标头,因此无需在到期日期之前向服务器请求新资源).

                  The solution should be general and work for unconditional requests. In this case, the response code is always 200 OK, but XHR returns a cached resource for the second request (e.g. the first response contains Expires header, so there is no need to ask a server for a new resource before the expiration date).

                  推荐答案

                  答案是Date header

                  The answer is Date header

                  • 如果日期标头在发送日期之前,则响应来自缓存.
                  • 如果日期标头晚于发送请求的日期,则响应是新的.

                  例如

                  • 来自缓存:请求于 11:00 发送,响应日期为 10:59
                  • 无缓存:请求在 11:00 发送,响应日期为 11:01

                  这篇关于如何检测 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 状态码?)
                  How to get response url in XMLHttpRequest?(如何在 XMLHttpRequest 中获取响应 url?)
                  <legend id='3TyVv'><style id='3TyVv'><dir id='3TyVv'><q id='3TyVv'></q></dir></style></legend>
                  <tfoot id='3TyVv'></tfoot>

                  <small id='3TyVv'></small><noframes id='3TyVv'>

                    • <bdo id='3TyVv'></bdo><ul id='3TyVv'></ul>

                          <tbody id='3TyVv'></tbody>

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