awesome-interview/book2/network-http-cache.html

22 lines
24 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en" dir="ltr" class="docs-wrapper docs-doc-page docs-version-current plugin-docs plugin-id-default docs-doc-id-book2/network-http-cache">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.3.1">
<title data-rh="true">HTTP 缓存机制 | HZFE - 剑指前端 Offer</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://febook.hzfe.org/awesome-interview/book2/network-http-cache"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docusaurus_version" content="current"><meta data-rh="true" name="docusaurus_tag" content="docs-default-current"><meta data-rh="true" name="docsearch:version" content="current"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-current"><meta data-rh="true" property="og:title" content="HTTP 缓存机制 | HZFE - 剑指前端 Offer"><meta data-rh="true" name="description" content="相关问题"><meta data-rh="true" property="og:description" content="相关问题"><link data-rh="true" rel="icon" href="/awesome-interview/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://febook.hzfe.org/awesome-interview/book2/network-http-cache"><link data-rh="true" rel="alternate" href="https://febook.hzfe.org/awesome-interview/book2/network-http-cache" hreflang="en"><link data-rh="true" rel="alternate" href="https://febook.hzfe.org/awesome-interview/book2/network-http-cache" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://PED5MQGL7T-dsn.algolia.net" crossorigin="anonymous"><link rel="search" type="application/opensearchdescription+xml" title="HZFE - 剑指前端 Offer" href="/awesome-interview/opensearch.xml">
<link rel="apple-touch-icon" href="/awesome-interview/img/badge.png">
<link rel="manifest" href="/awesome-interview/manifest.json">
<link rel="preconnect" href="https://hm.baidu.com">
<script>var _hmt=_hmt||[];!function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?c7cd0fd77ac518cc6ef46461cdc9524b";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(e,c)}()</script>
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js" async data-ad-client="ca-pub-9889934432771967"></script>
<script src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9889934432771967" async crossorigin="anonymous"></script><link rel="stylesheet" href="/awesome-interview/assets/css/styles.0f62048e.css">
<link rel="preload" href="/awesome-interview/assets/js/runtime~main.a75952d5.js" as="script">
<link rel="preload" href="/awesome-interview/assets/js/main.a5e14537.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbarHideable_m1mJ"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/awesome-interview/"><div class="navbar__logo"><img src="/awesome-interview/img/badge.svg" alt="HZFE" class="themedImage_ToTc themedImage--light_HNdA"><img src="/awesome-interview/img/badge.svg" alt="HZFE" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">剑指前端 Offer</b></a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/hzfe/awesome-interview" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">GitHub<svg width="13.5" height="13.5" aria-hidden="true" viewBox="0 0 24 24" class="iconExternalLink_nPIU"><path fill="currentColor" d="M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z"></path></svg></a><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="Scroll back to top" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebarViewport_Xe31"><div class="sidebar_njMd sidebarWithHideableNavbar_wUlq"><a tabindex="-1" class="sidebarLogo_isFc" href="/awesome-interview/"><img src="/awesome-interview/img/badge.svg" alt="HZFE" class="themedImage_ToTc themedImage--light_HNdA"><img src="/awesome-interview/img/badge.svg" alt="HZFE" class="themedImage_ToTc themedImage--dark_i4oU"><b>剑指前端 Offer</b></a><nav aria-label="Docs sidebar" class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/awesome-interview/about">关于我们</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-1 menu__list-item"><a class="menu__link" href="/awesome-interview/">前言</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/awesome-interview/book1/browser-cross-origin">模拟题一</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/awesome-interview/book2/browser-render-mechanism">模拟题二</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/browser-render-mechanism">浏览器:浏览器渲染机制</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/browser-garbage">浏览器:垃圾回收机制</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/engineer-babel">工程化Babel 的原理</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/frame-react-fiber">框架React Fiber 的作用和原理</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/frame-react-hoc-hooks">框架HOC vs Render Props vs Hooks</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/js-inherite">基础ES5、ES6 如何实现继承</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/js-new">基础New 操作符的原理</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/css-preprocessor">样式:谈谈 CSS 预处理器</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/awesome-interview/book2/network-http-cache">网络HTTP 缓存机制</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/coding-throttle-debounce">编码:实现节流防抖函数</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/algorithm-reverse-linked-list">算法:反转链表</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/awesome-interview/book2/topic-multi-pics-site-optimize">综合:多图站点性能优化</a></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/awesome-interview/book3/browser-event-loop">模拟题三</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/awesome-interview/book4/browser-router">模拟题四</a></div></li></ul></nav><button type="button" title="Collapse sidebar" aria-label="Collapse sidebar" class="button button--secondary button--outline collapseSidebarButton_PEFL"><svg width="20" height="20" aria-hidden="true" class="collapseSidebarButtonIcon_kv0_"><g fill="#7a7a7a"><path d="M9.992 10.023c0 .2-.062.399-.172.547l-4.996 7.492a.982.982 0 01-.828.454H1c-.55 0-1-.453-1-1 0-.2.059-.403.168-.551l4.629-6.942L.168 3.078A.939.939 0 010 2.528c0-.548.45-.997 1-.997h2.996c.352 0 .649.18.828.45L9.82 9.472c.11.148.172.347.172.55zm0 0"></path><path d="M19.98 10.023c0 .2-.058.399-.168.547l-4.996 7.492a.987.987 0 01-.828.454h-3c-.547 0-.996-.453-.996-1 0-.2.059-.403.168-.551l4.625-6.942-4.625-6.945a.939.939 0 01-.168-.55 1 1 0 01.996-.997h3c.348 0 .649.18.828.45l4.996 7.492c.11.148.168.347.168.55zm0 0"></path></g></svg></button></div></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="Breadcrumbs"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="Home page" class="breadcrumbs__link" href="/awesome-interview/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_YNFT"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">模拟题二</span><meta itemprop="position" content="1"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">网络HTTP 缓存机制</span><meta itemprop="position" content="2"></li></ul></nav><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><h1>HTTP 缓存机制</h1><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="相关问题">相关问题<a href="#相关问题" class="hash-link" aria-label="Direct link to 相关问题" title="Direct link to 相关问题"></a></h2><ul><li>了解浏览器的缓存机制吗</li><li>谈谈 HTTP 缓存</li><li>为什么要有缓存</li><li>缓存的优点是什么</li></ul><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="回答关键点">回答关键点<a href="#回答关键点" class="hash-link" aria-label="Direct link to 回答关键点" title="Direct link to 回答关键点"></a></h2><p><code>强缓存</code> <code>协商缓存</code></p><p>HTTP 缓存主要分为<strong>强缓存</strong><strong>协商缓存</strong></p><p><strong>强缓存</strong>可以通过 Expires / Cache-Control 控制,命中强缓存时不会发起网络请求,资源直接从本地获取,浏览器显示状态码 200 from cache。</p><p><strong>协商缓存</strong>可以通过 Last-Modified / If-Modified-Since 和 Etag / If-None-Match 控制,开启协商缓存时向服务器发送的请求会带上缓存标识,若命中协商缓存服务器返回 304 Not Modified 表示浏览器可以使用本地缓存文件,否则返回 200 OK 正常返回数据。</p><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="知识点深入">知识点深入<a href="#知识点深入" class="hash-link" aria-label="Direct link to 知识点深入" title="Direct link to 知识点深入"></a></h2><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="1-流程图">1. 流程图<a href="#1-流程图" class="hash-link" aria-label="Direct link to 1. 流程图" title="Direct link to 1. 流程图"></a></h3><p><img loading="lazy" src="https://user-images.githubusercontent.com/13888962/125894860-a0b9eecd-03b6-49ce-9612-9705b1fb6e78.png" alt="image" class="img_ev3q"></p><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="2强缓存">2.强缓存<a href="#2强缓存" class="hash-link" aria-label="Direct link to 2.强缓存" title="Direct link to 2.强缓存"></a></h3><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="21-expires">2.1 Expires<a href="#21-expires" class="hash-link" aria-label="Direct link to 2.1 Expires" title="Direct link to 2.1 Expires"></a></h4><ul><li>HTTP/1.0 产物。</li><li>优先级低于 Cache-control: max-age。</li><li>缺点:使用本地时间判断是否过期,而本地时间是可修改的且并非一定准确的。</li></ul><p>Expires 是由服务端返回的资源过期时间GMT 日期格式/时间戳),若用户本地时间在过期时间前,则不发送请求直接从本地获取资源。</p><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="22-cache-control">2.2 Cache-Control<a href="#22-cache-control" class="hash-link" aria-label="Direct link to 2.2 Cache-Control" title="Direct link to 2.2 Cache-Control"></a></h4><ul><li>HTTP/1.1 产物。</li><li>优先级高于 Expires。</li><li>正确区分 no-cache / no-store 的作用。</li></ul><p>Cache-Control 是用于页面缓存的通用消息头字段,可以通过指定指令来实现缓存机制。</p><p>常用的字段有:</p><ul><li><strong>max-age</strong> 设置缓存存储的最大时长,单位秒。</li><li><strong>s-max-age</strong> 与 max-age 用法一致,不过仅适用于代理服务器。</li><li><strong>public</strong> 表示响应可被任何对象缓存。</li><li><strong>private</strong> 表示响应只可被私有用户缓存,不能被代理服务器缓存。</li><li><strong>no-cache</strong> 强制客户端向服务器发起请求(禁用强缓存,可用协商缓存)。</li><li><strong>no-store</strong> 禁止一切缓存,包含协商缓存也不可用。</li><li><strong>must-revalidate</strong> 一旦资源过期,在成功向原始服务器验证之前,缓存不能用该资源响应后续请求。</li><li><strong>immutable</strong> 表示响应正文不会随时间改变(只要资源不过期就不发送请求)。</li></ul><p>值得注意的是,虽然以上常用字段都是响应头的字段,但是 Cache-Control 同时也支持请求头,例如 <code>Cache-Control: max-stale=&lt;seconds&gt;</code> 表明客户端愿意接收一个已经过期但不能超出<code>&lt;seconds&gt;</code>秒的资源。</p><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="23-拓展知识冷门考点">2.3 拓展知识(冷门考点)<a href="#23-拓展知识冷门考点" class="hash-link" aria-label="Direct link to 2.3 拓展知识(冷门考点)" title="Direct link to 2.3 拓展知识(冷门考点)"></a></h4><ul><li>HTTP/1.0 Pragma<ul><li>在 HTTP/1.0 时期用于禁用浏览器缓存 Pragma: no-cache。</li></ul></li><li>缓存位置<ul><li>从 Service Worker 中读取缓存(只支持 HTTPS</li><li>从内存读取缓存时 network 显示 memory cache。</li><li>从硬盘读取缓存时 network 显示 disk cache。</li><li>Push Cache推送缓存HTTP/2.0)。</li><li>优先级 Service Worker &gt; memory cache &gt; disk cache &gt; Push Cache。</li></ul></li><li>最佳实践:资源尽可能命中强缓存,且在资源文件更新时保证用户使用到最新的资源文件<ul><li>强缓存只会命中相同命名的资源文件。</li><li>在资源文件上加 hash 标识webpack 可在打包时在文件名上带上)。</li><li>通过更新资源文件名来强制更新命中强缓存的资源。</li></ul></li></ul><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="3-协商缓存">3. 协商缓存<a href="#3-协商缓存" class="hash-link" aria-label="Direct link to 3. 协商缓存" title="Direct link to 3. 协商缓存"></a></h3><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="31-etag--if-none-match">3.1 ETag / If-None-Match<a href="#31-etag--if-none-match" class="hash-link" aria-label="Direct link to 3.1 ETag / If-None-Match" title="Direct link to 3.1 ETag / If-None-Match"></a></h4><ul><li>通过唯一标识来验证缓存。</li><li>优先级高于 Last-Modified / If-Modified-Since。</li></ul><p>如果资源请求的响应头里含有 ETag客户端可以在后续的请求的头中带上 If-None-Match 头来验证缓存。若服务器判断资源标识一致,则返回 304 状态码告知浏览器可从本地读取缓存。</p><p>唯一标识内容是由服务端生成算法决定的,可以是资源内容生成的哈希值,也可以是最后修改时间戳的哈希值。所以 Etag 标识改变并不代表资源文件改变,反之亦然。</p><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="32-last-modified--if-modified-since">3.2 Last-Modified / If-Modified-Since<a href="#32-last-modified--if-modified-since" class="hash-link" aria-label="Direct link to 3.2 Last-Modified / If-Modified-Since" title="Direct link to 3.2 Last-Modified / If-Modified-Since"></a></h4><ul><li>通过资源的最后修改时间来验证缓存。</li><li>优先级低于 ETag / If-None-Match。</li><li>缺点:只能精确到秒,若 1s 内多次修改资源 Last-Modified 不会变化。</li></ul><p>如果资源请求的响应头里含有 Last-Modified客户端可以在后续的请求的头中带上 If-Modified-Since 头来验证缓存。若服务器判断资源最后修改时间一致,则返回 304 状态码告知浏览器可从本地读取缓存。</p><h4 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="33-拓展知识冷门考点">3.3 拓展知识(冷门考点)<a href="#33-拓展知识冷门考点" class="hash-link" aria-label="Direct link to 3.3 拓展知识(冷门考点)" title="Direct link to 3.3 拓展知识(冷门考点)"></a></h4><ul><li>ETag 在标识前面加 <code>W/</code> 前缀表示用弱比较算法If-None-Match 本身就只用弱比较算法)。</li><li>ETag 还可以配合 If-Match 检测当前请求是否为最新版本,若资源不匹配返回状态码 412 错误If-Match 不加 <code>W/</code> 时使用强比较算法)。</li></ul><h3 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="4-缓存的优缺点">4. 缓存的优缺点<a href="#4-缓存的优缺点" class="hash-link" aria-label="Direct link to 4. 缓存的优缺点" title="Direct link to 4. 缓存的优缺点"></a></h3><p><strong>优点</strong></p><ul><li>节省了不必要的数据传输,节省带宽。</li><li>减少服务端的负担,提高网站性能。</li><li>降低网络延迟,加快页面响应速度,增强用户体验。</li></ul><p><strong>缺点</strong></p><ul><li>不恰当的缓存设置可能会导致资源更新不及时,导致用户获取信息滞后。</li></ul><h2 class="anchor anchorWithHideOnScrollNavbar_WYt5" id="参考资料">参考资料<a href="#参考资料" class="hash-link" aria-label="Direct link to 参考资料" title="Direct link to 参考资料"></a></h2><ol><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching" target="_blank" rel="noopener noreferrer">HTTP Caching</a></li></ol></div></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><a class="pagination-nav__link pagination-nav__link--prev" href="/awesome-interview/book2/css-preprocessor"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">样式:谈谈 CSS 预处理器</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/awesome-interview/book2/coding-throttle-debounce"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">编码:实现节流防抖函数</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#相关问题" class="table-of-contents__link toc-highlight">相关问题</a></li><li><a href="#回答关键点" class="table-of-contents__link toc-highlight">回答关键点</a></li><li><a href="#知识点深入" class="table-of-contents__link toc-highlight">知识点深入</a><ul><li><a href="#1-流程图" class="table-of-contents__link toc-highlight">1. 流程图</a></li><li><a href="#2强缓存" class="table-of-contents__link toc-highlight">2.强缓存</a><ul><li><a href="#21-expires" class="table-of-contents__link toc-highlight">2.1 Expires</a></li><li><a href="#22-cache-control" class="table-of-contents__link toc-highlight">2.2 Cache-Control</a></li><li><a href="#23-拓展知识冷门考点" class="table-of-contents__link toc-highlight">2.3 拓展知识(冷门考点)</a></li></ul></li><li><a href="#3-协商缓存" class="table-of-contents__link toc-highlight">3. 协商缓存</a><ul><li><a href="#31-etag--if-none-match" class="table-of-contents__link toc-highlight">3.1 ETag / If-None-Match</a></li><li><a href="#32-last-modified--if-modified-since" class="table-of-contents__link toc-highlight">3.2 Last-Modified / If-Modified-Since</a></li><li><a href="#33-拓展知识冷门考点" class="table-of-contents__link toc-highlight">3.3 拓展知识(冷门考点)</a></li></ul></li><li><a href="#4-缓存的优缺点" class="table-of-contents__link toc-highlight">4. 缓存的优缺点</a></li></ul></li><li><a href="#参考资料" class="table-of-contents__link toc-highlight">参考资料</a></li></ul></div></div></div><div class="row"><div class="col"><div class="react-utterences"><div>Loading script...</div></div></div><div class="col col--3"></div></div></div></main></div></div></div>
<script src="/awesome-interview/assets/js/runtime~main.a75952d5.js"></script>
<script src="/awesome-interview/assets/js/main.a5e14537.js"></script>
</body>
</html>