{"id":589,"date":"2025-12-07T10:08:58","date_gmt":"2025-12-07T02:08:58","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=589"},"modified":"2025-12-07T10:08:58","modified_gmt":"2025-12-07T02:08:58","slug":"%e5%89%8d%e7%ab%af%e5%b8%b8%e8%a7%81%e7%9a%84%e6%95%b0%e6%8d%ae%e7%bc%93%e5%ad%98%e6%96%b9%e6%a1%88%e5%8f%8a%e5%85%b6%e5%ae%9e%e7%8e%b0%e7%bb%86%e8%8a%82","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/07\/%e5%89%8d%e7%ab%af%e5%b8%b8%e8%a7%81%e7%9a%84%e6%95%b0%e6%8d%ae%e7%bc%93%e5%ad%98%e6%96%b9%e6%a1%88%e5%8f%8a%e5%85%b6%e5%ae%9e%e7%8e%b0%e7%bb%86%e8%8a%82\/","title":{"rendered":"\u524d\u7aef\u5e38\u89c1\u7684\u6570\u636e\u7f13\u5b58\u65b9\u6848\u53ca\u5176\u5b9e\u73b0\u7ec6\u8282"},"content":{"rendered":"\n<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd <strong>\u524d\u7aef\u5e38\u89c1\u7684\u6570\u636e\u7f13\u5b58\u65b9\u6848\u53ca\u5176\u5b9e\u73b0\u7ec6\u8282\uff08\u8d85\u5b8c\u6574\u603b\u7ed3\uff09<\/strong>\uff0c\u6db5\u76d6\u6d4f\u89c8\u5668\u7aef\u6240\u6709\u4e3b\u6d41\u7f13\u5b58\u65b9\u5f0f\uff0c\u5e76\u7ed9\u51fa\u4f18\u7f3a\u70b9\u3001\u4f7f\u7528\u573a\u666f\u3001\u4ee3\u7801\u793a\u4f8b\u4e0e\u6ce8\u610f\u70b9\u3002<\/p>\n\n\n\n<p>\u5185\u5bb9\u7ed3\u6784\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u524d\u7aef\u7f13\u5b58\u7684\u6838\u5fc3\u5206\u5c42<\/li>\n\n\n\n<li>7 \u5927\u5e38\u7528\u7f13\u5b58\u65b9\u6848<\/li>\n\n\n\n<li>\u5404\u65b9\u6848\u4f18\u7f3a\u70b9\u5bf9\u6bd4<\/li>\n\n\n\n<li>\u5e38\u89c1\u7684\u7f13\u5b58\u67b6\u6784\u6700\u4f73\u5b9e\u8df5\uff08\u542b Vue \/ React \uff09<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 1. \u524d\u7aef\u7f13\u5b58\u7684\u6838\u5fc3\u5206\u5c42<\/h1>\n\n\n\n<p>\u524d\u7aef\u7f13\u5b58\u53ef\u5206\u4e3a\u56db\u5927\u5c42\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u5c42\u7ea7<\/th><th>\u6280\u672f<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td><strong>HTTP \u7f13\u5b58\u5c42<\/strong><\/td><td>Cache-Control \/ ETag<\/td><td>\u6d4f\u89c8\u5668\u81ea\u52a8\u7f13\u5b58\u8d44\u6e90\uff08HTML\/CSS\/JS\/\u56fe\u7247\uff09<\/td><\/tr><tr><td><strong>\u5185\u5b58\u7f13\u5b58<\/strong><\/td><td>JS \u53d8\u91cf\u3001Vue\/React \u72b6\u6001\u7ba1\u7406<\/td><td>\u9875\u9762\u5237\u65b0\u5373\u6d88\u5931\uff0c\u4f46\u6700\u5feb<\/td><\/tr><tr><td><strong>\u672c\u5730\u5b58\u50a8<\/strong><\/td><td>localStorage \/ sessionStorage<\/td><td>\u7b80\u5355\u7684 key-value \u5b58\u50a8<\/td><\/tr><tr><td><strong>\u6301\u4e45\u5316\u7f13\u5b58<\/strong><\/td><td>IndexedDB \/ CacheStorage<\/td><td>\u5b58\u5927\u91cf\u7ed3\u6784\u5316\u6570\u636e\u3001\u79bb\u7ebf\u80fd\u529b\u6700\u5f3a<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 2. \u524d\u7aef\u5e38\u89c1\u4e03\u5927\u7f13\u5b58\u65b9\u6848<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u2460 <strong>HTTP \u7f13\u5b58\uff08\u5f3a\u7f13\u5b58 + \u534f\u5546\u7f13\u5b58\uff09<\/strong><\/h2>\n\n\n\n<p>\u6d4f\u89c8\u5668\u539f\u751f\u673a\u5236\uff0c\u4e3b\u8981\u9488\u5bf9\u9759\u6001\u8d44\u6e90\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5f3a\u7f13\u5b58\uff08\u76f4\u63a5\u8fd4\u56de\u7f13\u5b58\uff0c\u4e0d\u53d1\u8bf7\u6c42\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Cache-Control: max-age=31536000<\/code><\/li>\n\n\n\n<li><code>Expires: xxx<\/code><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u534f\u5546\u7f13\u5b58\uff08\u5411\u670d\u52a1\u7aef\u786e\u8ba4\u662f\u5426\u8fc7\u671f\uff09<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ETag \/ If-None-Match<\/code><\/li>\n\n\n\n<li><code>Last-Modified \/ If-Modified-Since<\/code><\/li>\n<\/ul>\n\n\n\n<p>\u2714 \u4f18\u70b9\uff1a\u6027\u80fd\u6700\u4f73\uff0c\u7701\u6d41\u91cf<br>\u2718 \u7f3a\u70b9\uff1a\u524d\u7aef\u65e0\u6cd5\u7cbe\u51c6\u63a7\u5236\uff0c\u53ea\u9002\u7528\u4e8e\u9759\u6001\u6587\u4ef6<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461 <strong>\u5185\u5b58\u7f13\u5b58\uff08Memory Cache\uff09<\/strong><\/h2>\n\n\n\n<p>\u5b58\u50a8\u5728\u5185\u5b58\uff0c\u9875\u9762\u5173\u95ed\u540e\u6d88\u5931\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u5178\u578b\u573a\u666f<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Vue \u4e2d\u7684 <code>store<\/code>\uff08pinia\/vuex\uff09<\/li>\n\n\n\n<li>React \u4e2d\u7684 <code>useState<\/code> \/ <code>useContext<\/code><\/li>\n\n\n\n<li>\u5168\u5c40 JS \u5bf9\u8c61\u7f13\u5b58<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst cache = {};\n\nfunction getData() {\n  if (cache.data) return Promise.resolve(cache.data);\n\n  return fetch(&#039;\/api\/data&#039;).then(res =&gt; {\n    cache.data = res;\n    return res;\n  });\n}\n\n<\/pre><\/div>\n\n\n<p>\u2714 \u4f18\u70b9\uff1a\u6700\u5feb\u901f\u3001\u96f6 IO<br>\u2718 \u7f3a\u70b9\uff1a\u5237\u65b0\u9875\u9762\u5c31\u6ca1\u4e86<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2462 <strong>localStorage\uff08\u6c38\u4e45\u4fdd\u5b58\uff09<\/strong><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nlocalStorage.setItem(&quot;token&quot;, &quot;123456&quot;);\nlocalStorage.getItem(&quot;token&quot;);\nlocalStorage.removeItem(&quot;token&quot;);\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u7279\u70b9<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6c38\u4e45\u4fdd\u5b58\uff0c\u9664\u975e\u7528\u6237\u624b\u52a8\u6e05\u9664<\/li>\n\n\n\n<li>\u5927\u7ea6 5MB \u5927\u5c0f<\/li>\n\n\n\n<li>\u540c\u6b65 API\uff08\u4f1a\u963b\u585e\u4e3b\u7ebf\u7a0b\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u2714 \u7528\u4e8e\u6301\u4e45\u6570\u636e\uff1atoken\u3001\u7528\u6237\u504f\u597d\u8bbe\u7f6e<br>\u2718 \u4e0d\u9002\u5408\u5b58\u5927\u91cf\u6570\u636e\uff08\u540c\u6b65\u963b\u585e\uff09<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2463 <strong>sessionStorage\uff08\u4f1a\u8bdd\u7ea7\u522b\u7f13\u5b58\uff09<\/strong><\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nsessionStorage.setItem(&quot;step&quot;, &quot;2&quot;);\n\n<\/pre><\/div>\n\n\n<p>\u7279\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6807\u7b7e\u9875\u7ea7\u522b\u72ec\u7acb<\/li>\n\n\n\n<li>\u9875\u9762\u5173\u95ed\u5373\u5931\u6548<\/li>\n<\/ul>\n\n\n\n<p>\u2714 \u9002\u5408\uff1a\u8868\u5355\u5206\u6b65\u9aa4\u586b\u5199\u3001\u4e34\u65f6\u72b6\u6001\u4fdd\u6301<br>\u2718 \u548c localStorage \u4e00\u6837\u662f\u540c\u6b65 API<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2464 <strong>Cookie\uff08\u5e26\u81ea\u52a8\u9644\u52a0\u529f\u80fd\uff09<\/strong><\/h2>\n\n\n\n<p>\u524d\u7aef\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocument.cookie = &quot;id=123; max-age=3600; path=\/&quot;;\n\n<\/pre><\/div>\n\n\n<p>\u670d\u52a1\u7aef\u54cd\u5e94\u5934\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSet-Cookie: token=xxx; HttpOnly; Secure; SameSite=Lax\n\n<\/pre><\/div>\n\n\n<p>\u7279\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f1a\u81ea\u52a8\u968f\u8bf7\u6c42\u53d1\u9001\u5230\u670d\u52a1\u7aef<\/li>\n\n\n\n<li>\u6709\u8fc7\u671f\u65f6\u95f4<\/li>\n\n\n\n<li>4KB \u5de6\u53f3<\/li>\n<\/ul>\n\n\n\n<p>\u2714 \u6700\u9002\u5408\uff1asessionID\u3001\u7b80\u5355 token<br>\u2718 \u4e0d\u9002\u5408\u5b58\u5927\u91cf\u6570\u636e<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2465 <strong>IndexedDB\uff08\u6d4f\u89c8\u5668\u6570\u636e\u5e93\uff0c\u9002\u5408\u5927\u91cf\u6570\u636e\uff09<\/strong><\/h2>\n\n\n\n<p>\u9002\u7528\u573a\u666f\uff1a\u5927\u6570\u636e\u7ed3\u6784\u5316\u5b58\u50a8\u3001\u79bb\u7ebf\u5e94\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff08\u7b80\u5316\u7248\uff09<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nconst dbRequest = indexedDB.open(&quot;MyDB&quot;, 1);\n\ndbRequest.onupgradeneeded = function() {\n  const db = dbRequest.result;\n  db.createObjectStore(&quot;users&quot;, { keyPath: &quot;id&quot; });\n};\n\ndbRequest.onsuccess = function() {\n  const db = dbRequest.result;\n  const tx = db.transaction(&quot;users&quot;, &quot;readwrite&quot;);\n  tx.objectStore(&quot;users&quot;).put({ id: 1, name: &#039;Tom&#039; });\n};\n\n<\/pre><\/div>\n\n\n<p>\u2714 \u4f18\u70b9<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5f02\u6b65\u3001\u6027\u80fd\u597d\u3001\u4e0d\u963b\u585e<\/li>\n\n\n\n<li>\u57fa\u672c\u6ca1\u6709\u5bb9\u91cf\u9650\u5236\uff08GB \u7ea7\u522b\uff09<\/li>\n\n\n\n<li>\u9002\u7528\u4e8e\u5927\u578b\u79bb\u7ebf\u9879\u76ee\uff08\u5982 PWA\uff09<\/li>\n<\/ul>\n\n\n\n<p>\u2718 \u7f3a\u70b9<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>API \u7e41\u7410\uff0c\u9700\u8981\u5c01\u88c5<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u2466 <strong>Cache API\uff08PWA\u3001Service Worker \u79bb\u7ebf\u7f13\u5b58\uff09<\/strong><\/h2>\n\n\n\n<p>\u4e3b\u8981\u7528\u4e8e\u7f13\u5b58\u8bf7\u6c42\u54cd\u5e94\uff0c\u4e0e HTTP \u7f13\u5b58\u914d\u5408\u4f7f\u7528\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u7f13\u5b58\u7f51\u7edc\u8bf7\u6c42<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncaches.open(&quot;v1&quot;).then(cache =&gt; {\n  cache.add(&quot;\/api\/user&quot;);\n});\n\n<\/pre><\/div>\n\n\n<p>Service Worker \u4e2d\u4f7f\u7528\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nself.addEventListener(&quot;fetch&quot;, event =&gt; {\n  event.respondWith(\n    caches.match(event.request).then(resp =&gt; resp || fetch(event.request))\n  );\n});\n\n<\/pre><\/div>\n\n\n<p>\u2714 \u8d85\u5f3a\u79bb\u7ebf\u80fd\u529b<br>\u2714 \u53ef\u7f13\u5b58\u6574\u4e2a\u7f51\u7ad9<br>\u2718 \u9700\u8981 Service Worker \u914d\u7f6e<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 3. \u5404\u7f13\u5b58\u65b9\u5f0f\u5bf9\u6bd4\uff08\u6700\u5b9e\u7528\u8868\u683c\uff09<\/h1>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7f13\u5b58\u7c7b\u578b<\/th><th>\u6301\u4e45\u6027<\/th><th>\u5bb9\u91cf<\/th><th>\u662f\u5426\u963b\u585e<\/th><th>\u662f\u5426\u968f\u8bf7\u6c42\u53d1\u9001<\/th><th>\u4f7f\u7528\u573a\u666f<\/th><\/tr><\/thead><tbody><tr><td><strong>Memory<\/strong><\/td><td>\u9875\u9762\u751f\u547d\u5468\u671f<\/td><td>\u51e0 MB<\/td><td>\u5feb<\/td><td>\u5426<\/td><td>\u72b6\u6001\u7ba1\u7406\u3001\u9875\u9762\u53d8\u91cf<\/td><\/tr><tr><td><strong>localStorage<\/strong><\/td><td>\u6c38\u4e45<\/td><td>~5MB<\/td><td>\u963b\u585e<\/td><td>\u5426<\/td><td>token\u3001\u504f\u597d\u8bbe\u7f6e<\/td><\/tr><tr><td><strong>sessionStorage<\/strong><\/td><td>\u4f1a\u8bdd<\/td><td>~5MB<\/td><td>\u963b\u585e<\/td><td>\u5426<\/td><td>\u8868\u5355\u4e34\u65f6\u7f13\u5b58<\/td><\/tr><tr><td><strong>Cookie<\/strong><\/td><td>\u53ef\u8bbe<\/td><td>4KB<\/td><td>\u5c11\u91cf\u963b\u585e<\/td><td>\u2714 \u4f1a\u81ea\u52a8\u53d1\u9001<\/td><td>\u767b\u5f55 session<\/td><\/tr><tr><td><strong>IndexedDB<\/strong><\/td><td>\u6c38\u4e45<\/td><td>\u6570\u767e MB~GB<\/td><td>\u5f02\u6b65<\/td><td>\u5426<\/td><td>\u5927\u91cf\u6570\u636e\u3001\u79bb\u7ebf<\/td><\/tr><tr><td><strong>Cache API<\/strong><\/td><td>\u6c38\u4e45<\/td><td>\u5927<\/td><td>\u5f02\u6b65<\/td><td>\u5426<\/td><td>PWA \u79bb\u7ebf\u7f13\u5b58<\/td><\/tr><tr><td><strong>HTTP Cache<\/strong><\/td><td>\u6d4f\u89c8\u5668\u63a7\u5236<\/td><td>\u5927<\/td><td>&#8211;<\/td><td>&#8211;<\/td><td>\u9759\u6001\u8d44\u6e90\u4f18\u5316<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\u2705 4. \u524d\u7aef\u7f13\u5b58\u6700\u4f73\u5b9e\u8df5\uff08\u5b9e\u6218\u65b9\u6848\uff09<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf1f \u65b9\u6848 A\uff1a\u63a5\u53e3\u7f13\u5b58\uff08\u5e38\u7528\u4e8e Vue\/React\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nasync function fetchWithCache(key, url) {\n  const cache = localStorage.getItem(key);\n  if (cache) return JSON.parse(cache);\n\n  const res = await fetch(url).then(r =&gt; r.json());\n  localStorage.setItem(key, JSON.stringify(res));\n  return res;\n}\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf1f \u65b9\u6848 B\uff1aVue \u9879\u76ee\u4e2d\u4f7f\u7528 \u201c\u591a\u7ea7\u7f13\u5b58\u67b6\u6784\u201d<\/h2>\n\n\n\n<p><strong>\u63a8\u8350\u6a21\u5f0f\uff1a\u5185\u5b58 &gt; localStorage &gt; IndexedDB<\/strong><\/p>\n\n\n\n<p>\u6d41\u7a0b\uff1a<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\u7528\u6237\u8bbf\u95ee \u2192 \u5185\u5b58\u6709\uff1f \u2192 localStorage \u6709\uff1f \u2192 IndexedDB \u6709\uff1f \u2192 \u8bf7\u6c42\u670d\u52a1\u5668\n\n<\/pre><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udf1f \u65b9\u6848 C\uff1aReact \u9879\u76ee\u4e2d\u4f7f\u7528 SWR \u6216 React Query\uff08\u81ea\u52a8\u7f13\u5b58\uff09<\/h2>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport useSWR from &quot;swr&quot;;\n\nconst { data } = useSWR(&quot;\/api\/user&quot;, url =&gt; fetch(url).then(r =&gt; r.json()));\n\n<\/pre><\/div>\n\n\n<p>\u2714 \u5185\u5b58\u7f13\u5b58<br>\u2714 \u7f13\u5b58\u8fc7\u671f<br>\u2714 \u81ea\u52a8\u91cd\u8bd5<br>\u2714 \u5931\u6548\u5237\u65b0<\/p>\n\n\n\n<p>\u8fd9\u662f\u524d\u7aef\u6700\u4f73\u7f13\u5b58\u65b9\u6848\u4e4b\u4e00\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udfaf \u603b\u7ed3\uff08\u53ef\u590d\u5236\uff09<\/h1>\n\n\n\n<p>\u524d\u7aef\u7f13\u5b58\u65b9\u6848\u53ef\u5206\u4e3a 7 \u5927\u7c7b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>HTTP \u7f13\u5b58<\/strong>\uff08\u9759\u6001\u8d44\u6e90\uff09<\/li>\n\n\n\n<li><strong>Memory Cache<\/strong>\uff08\u901f\u5ea6\u6700\u5feb\uff09<\/li>\n\n\n\n<li><strong>localStorage<\/strong>\uff08\u6c38\u4e45\u7f13\u5b58\uff09<\/li>\n\n\n\n<li><strong>sessionStorage<\/strong>\uff08\u4f1a\u8bdd\u7ea7\u522b\uff09<\/li>\n\n\n\n<li><strong>Cookie<\/strong>\uff08\u968f\u8bf7\u6c42\u53d1\u9001\uff09<\/li>\n\n\n\n<li><strong>IndexedDB<\/strong>\uff08\u5927\u91cf\u6570\u636e + \u79bb\u7ebf\uff09<\/li>\n\n\n\n<li><strong>Cache API<\/strong>\uff08PWA \u7ea7\u522b\u79bb\u7ebf\uff09<\/li>\n<\/ol>\n\n\n\n<p>\u9879\u76ee\u5efa\u8bae\u4f7f\u7528 <strong>\u591a\u7ea7\u7f13\u5b58\u4f53\u7cfb<\/strong>\uff0c\u6839\u636e\u573a\u666f\u7075\u6d3b\u642d\u914d\uff1a<\/p>\n\n\n\n<p>\u2714 \u8f7b\u91cf\u6570\u636e \u2192 localStorage<br>\u2714 \u8868\u5355\u72b6\u6001 \u2192 sessionStorage<br>\u2714 \u767b\u5f55\u72b6\u6001 \u2192 Cookie \/ localStorage<br>\u2714 \u5927\u89c4\u6a21\u6570\u636e \u2192 IndexedDB<br>\u2714 \u79bb\u7ebf\u5e94\u7528 \u2192 Cache API<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7ed9\u4f60\u4e00\u4efd \u524d\u7aef\u5e38\u89c1\u7684\u6570\u636e\u7f13\u5b58\u65b9\u6848\u53ca\u5176\u5b9e\u73b0\u7ec6\u8282\uff08\u8d85\u5b8c\u6574\u603b\u7ed3\uff09\uff0c\u6db5\u76d6\u6d4f\u89c8\u5668\u7aef\u6240\u6709&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/07\/%e5%89%8d%e7%ab%af%e5%b8%b8%e8%a7%81%e7%9a%84%e6%95%b0%e6%8d%ae%e7%bc%93%e5%ad%98%e6%96%b9%e6%a1%88%e5%8f%8a%e5%85%b6%e5%ae%9e%e7%8e%b0%e7%bb%86%e8%8a%82\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[49],"tags":[],"class_list":["post-589","post","type-post","status-publish","format-standard","hentry","category-javascript"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/589","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=589"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/589\/revisions"}],"predecessor-version":[{"id":590,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/589\/revisions\/590"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}