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

      <legend id='PIQRy'><style id='PIQRy'><dir id='PIQRy'><q id='PIQRy'></q></dir></style></legend>

        <tfoot id='PIQRy'></tfoot>

      1. <small id='PIQRy'></small><noframes id='PIQRy'>

        如何判断 XMLHTTPRequest 是否命中浏览器缓存

        时间:2023-10-13

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

              <tbody id='E6P6J'></tbody>
              <bdo id='E6P6J'></bdo><ul id='E6P6J'></ul>

                <legend id='E6P6J'><style id='E6P6J'><dir id='E6P6J'><q id='E6P6J'></q></dir></style></legend>
                1. <tfoot id='E6P6J'></tfoot>
                  <i id='E6P6J'><tr id='E6P6J'><dt id='E6P6J'><q id='E6P6J'><span id='E6P6J'><b id='E6P6J'><form id='E6P6J'><ins id='E6P6J'></ins><ul id='E6P6J'></ul><sub id='E6P6J'></sub></form><legend id='E6P6J'></legend><bdo id='E6P6J'><pre id='E6P6J'><center id='E6P6J'></center></pre></bdo></b><th id='E6P6J'></th></span></q></dt></tr></i><div id='E6P6J'><tfoot id='E6P6J'></tfoot><dl id='E6P6J'><fieldset id='E6P6J'></fieldset></dl></div>
                  本文介绍了如何判断 XMLHTTPRequest 是否命中浏览器缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如果可以判断(在 javascript 执行中)GET XMLHTTPRequest 是否命中浏览器缓存而不是从服务器获取响应?

                  If it possible to tell (within javascript execution) if a GET XMLHTTPRequest hit the browser cache instead of getting its response from the server?

                  推荐答案

                  来自 XMLHttpRequest 规范:

                  对于用户代理导致的 304 Not Modified 响应生成的条件请求用户代理必须像服务器一样操作用适当的内容给出了 200 OK 响应.

                  For 304 Not Modified responses that are a result of a user agent generated conditional request the user agent must act as if the server gave a 200 OK response with the appropriate content.

                  换句话说,浏览器将始终给出状态码 200 OK,即使对于命中浏览器缓存的请求也是如此.

                  In other words, the browser will always give status code 200 OK, even for requests that hit the browser cache.

                  但是,规范中还说:

                  用户代理必须允许作者请求标头覆盖自动缓存验证(例如 If-None-Match 或 If-Modified-Since),在这种情况下必须通过 304 Not Modified 响应.

                  The user agent must allow author request headers to override automatic cache validation (e.g. If-None-Match or If-Modified-Since), in which case 304 Not Modified responses must be passed through.

                  因此,有一种解决方法可以使 304 Not Modified 响应对您的 JavaScript 代码可见.

                  So, there is a workaround to make the 304 Not Modified responses visible to your JavaScript code.

                  这篇关于如何判断 XMLHTTPRequest 是否命中浏览器缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 FormData 转换为查询字符串的更简单方法 下一篇:如何强制程序等到 JavaScript 中的 HTTP 请求完成?

                  相关文章

                  最新文章

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

                  • <bdo id='qi8EW'></bdo><ul id='qi8EW'></ul>

                  <tfoot id='qi8EW'></tfoot>

                    1. <small id='qi8EW'></small><noframes id='qi8EW'>