mirror of
https://github.com/arthurfiorette/axios-cache-interceptor.git
synced 2026-01-25 14:08:29 +00:00
315 lines
77 KiB
HTML
315 lines
77 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en-US" dir="ltr">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||
<title>Invalidating Cache | Axios Cache Interceptor</title>
|
||
|
||
<link rel="preload stylesheet" href="/assets/style.44296ddc.css" as="style">
|
||
|
||
<script type="module" src="/assets/app.69373094.js"></script>
|
||
<link rel="preload" href="/assets/inter-roman-latin.2ed14f66.woff2" as="font" type="font/woff2" crossorigin="">
|
||
<link rel="modulepreload" href="/assets/chunks/framework.bc25502e.js">
|
||
<link rel="modulepreload" href="/assets/chunks/theme.48bb6f46.js">
|
||
<link rel="modulepreload" href="/assets/guide_invalidating-cache.md.2c8f5834.lean.js">
|
||
<link rel="icon" href="/favicon.ico', type: 'image/x-icon">
|
||
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
|
||
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
|
||
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
|
||
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
|
||
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
|
||
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
|
||
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
|
||
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
|
||
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
|
||
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
|
||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
|
||
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
|
||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
|
||
<link rel="manifest" href="/manifest.json">
|
||
<meta name="msapplication-TileColor" content="#e5972a">
|
||
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
|
||
<meta name="theme-color" content="#e5972a">
|
||
<meta name="description" content="Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!">
|
||
<meta property="og:url" content="https://axios-cache-interceptor.js.org">
|
||
<meta property="og:type" content="website">
|
||
<meta property="og:title" content="Axios Cache Interceptor">
|
||
<meta property="og:description" content="Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!">
|
||
<meta property="og:image" content="/preview.png">
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta property="twitter:domain" content="axios-cache-interceptor.js.org">
|
||
<meta property="twitter:url" content="https://axios-cache-interceptor.js.org">
|
||
<meta name="twitter:title" content="Axios Cache Interceptor">
|
||
<meta name="twitter:description" content="Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!">
|
||
<meta name="twitter:image" content="/preview.png">
|
||
<meta name="google-site-verification" content="u9Nw6WpRrWDhdPTAv-LGIE9aJ0C15t7zkjuaUizDJnA">
|
||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-K548ZF395X"></script>
|
||
<script>function gtag(){dataLayer.push(arguments)}window.dataLayer=window.dataLayer||[],gtag("js",new Date),gtag("config","G-K548ZF395X");</script>
|
||
<script type="application/ld+json">{"@context":"http://www.schema.org","@type":"Organization","name":"Axios Cache Interceptor","url":"https://axios-cache-interceptor.js.org","sameAs":["https://github.com/ArthurFiorette/axios-cache-interceptor"],"datePublished":"2022-01-17","dateModified":"2022-01-17","logo":"https://axios-cache-interceptor.js.org/preview.png","image":"https://axios-cache-interceptor.js.org/preview.png","description":"Axios Cache Interceptor is a small and efficient cache interceptor for axios.","headline":"A small and efficient cache interceptor for axios."}</script>
|
||
<script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
|
||
<script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
|
||
</head>
|
||
<body>
|
||
<div id="app"><div class="Layout" data-v-721252dc><!--[--><!--]--><!--[--><span tabindex="-1" data-v-449c9299></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-449c9299> Skip to content </a><!--]--><!----><header class="VPNav" data-v-721252dc data-v-f5b8d2af><div class="VPNavBar has-sidebar" data-v-f5b8d2af data-v-f0dc2006><div class="container" data-v-f0dc2006><div class="title" data-v-f0dc2006><div class="VPNavBarTitle has-sidebar" data-v-f0dc2006 data-v-11ba5966><a class="title" href="/" data-v-11ba5966><!--[--><!--]--><!----><!--[-->Axios Cache Interceptor<!--]--><!--[--><!--]--></a></div></div><div class="content" data-v-f0dc2006><div class="curtain" data-v-f0dc2006></div><div class="content-body" data-v-f0dc2006><!--[--><!--]--><div class="VPNavBarSearch search" data-v-f0dc2006><!--[--><!----><div id="docsearch"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><svg class="DocSearch-Search-Icon" width="20" height="20" viewBox="0 0 20 20" aria-label="search icon"><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"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-f0dc2006 data-v-dc8e72cc><span id="main-nav-aria-label" class="visually-hidden" data-v-dc8e72cc>Main Navigation</span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/guide" tabindex="0" data-v-dc8e72cc data-v-4f2196be><!--[--><span data-v-4f2196be>Guide</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/config" tabindex="0" data-v-dc8e72cc data-v-4f2196be><!--[--><span data-v-4f2196be>Config</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/others/license" tabindex="0" data-v-dc8e72cc data-v-4f2196be><!--[--><span data-v-4f2196be>Others</span><!--]--></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-dc8e72cc data-v-01e59011><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-01e59011><span class="text" data-v-01e59011><!----><span data-v-01e59011>Latest</span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="text-icon" data-v-01e59011><path d="M12,16c-0.3,0-0.5-0.1-0.7-0.3l-6-6c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l5.3,5.3l5.3-5.3c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-6,6C12.5,15.9,12.3,16,12,16z"></path></svg></span></button><div class="menu" data-v-01e59011><div class="VPMenu" data-v-01e59011 data-v-3c10fc56><div class="items" data-v-3c10fc56><!--[--><!--[--><div class="VPMenuLink" data-v-3c10fc56 data-v-151cf53d><a class="VPLink link vp-external-link-icon" href="https://axios-cache-interceptor.js.org/v0/" target="_blank" rel="noreferrer" data-v-151cf53d><!--[-->v0.x<!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-f0dc2006 data-v-ff6548c4><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-ff6548c4 data-v-370bd507 data-v-08e8f1e7><span class="check" data-v-08e8f1e7><span class="icon" data-v-08e8f1e7><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-370bd507><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-370bd507><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-f0dc2006 data-v-6024313c data-v-a0caf181><!--[--><a class="VPSocialLink no-icon" href="https://github.com/arthurfiorette/axios-cache-interceptor" aria-label="github" target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="https://npmjs.com/package/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://simpleicons.org/?q=npm -->
|
||
|
||
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0 0 24 24">
|
||
<title>npm</title>
|
||
<path d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z" />
|
||
</svg>
|
||
</a><a class="VPSocialLink no-icon" href="https://www.jsdelivr.com/package/npm/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://simpleicons.org/?q=jsdelivr -->
|
||
|
||
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0 0 24 24">
|
||
<title>jsDelivr</title>
|
||
<path d="M11.851 0L.811 4.02l1.56 14.7L11.85 24l9.6-5.28 1.74-14.76zm.062 4.622a6.668 6.75 0 0 1 2.666.572 12.507 12.507 0 0 0-2.59 1.95c-.045-.02-.092-.031-.138-.045a1.181 1.181 0 0 0-.346-.056c-.071 0-.141.01-.21.021a8.91 8.91 0 0 1-.615-2.318 6.668 6.75 0 0 1 1.171-.122 6.668 6.75 0 0 1 .062-.002zm-1.99.312a9.763 9.763 0 0 0 .69 2.504 1.213 1.213 0 0 0-.328.825 1.202 1.202 0 0 0 .18.63c-.937 1.294-1.656 2.803-1.905 4.31-.01.056-.013.11-.02.166-.282.09-.515.284-.656.54-.987-.333-1.885-.968-2.615-2.022a6.668 6.75 0 0 1-.026-.515 6.668 6.75 0 0 1 4.68-6.438zm5.507.709a6.668 6.75 0 0 1 2.53 2.9c-.377.953-1.049 1.892-1.893 2.727a1.242 1.242 0 0 0-.644-.184 1.243 1.243 0 0 0-.768.27c-.462-.354-.91-.737-1.318-1.168-.333-.35-.637-.73-.921-1.123.19-.215.31-.494.31-.802 0-.212-.061-.41-.159-.586 1.058-1.008 2.112-1.67 2.863-2.034zm-3.925 1.982a.624.624 0 0 1 .346.114.624.624 0 0 1 .292.524.624.624 0 0 1-.292.524.626.626 0 0 1-.346.113.634.634 0 0 1-.638-.637c0-.355.283-.638.638-.638zm-.441 1.771a1.205 1.205 0 0 0 .675.062c.036.05.075.097.112.148a11.438 11.438 0 0 0 .921 1.119 12.103 12.103 0 0 0 1.446 1.277c-.032.11-.054.224-.054.342a1.236 1.236 0 0 0 .066.38 9.91 9.91 0 0 1-2.118 1.042c-.087.029-.173.052-.261.078a7.735 7.735 0 0 1-1.87.332 1.15 1.15 0 0 0-.66-.773c.004-.024.005-.049.01-.073.219-1.333.873-2.73 1.733-3.934zm7.272.19a6.668 6.75 0 0 1 .245 1.786 6.668 6.75 0 0 1-.259 1.856 9.993 9.993 0 0 1-1.666-.63 1.243 1.243 0 0 0-.065-.713 9.434 9.434 0 0 0 1.745-2.3zm-2.913 2.101c.367 0 .657.291.657.658s-.291.657-.657.657c-.367 0-.658-.29-.658-.657s.29-.658.658-.658zm.837 1.59a10.79 10.79 0 0 0 1.802.688 6.668 6.75 0 0 1-6.149 4.157 6.668 6.75 0 0 1-.062-.004 6.668 6.75 0 0 1-.042 0c-.087-.042-.168-.08-.266-.129-.312-.154-.667-.352-.846-.5a3.796 3.796 0 0 1-1.294-2.03c.21-.111.38-.284.487-.495a8.428 8.428 0 0 0 1.96-.306 9.11 9.11 0 0 0 .513-.154 11.083 11.083 0 0 0 2.341-1.13c.205.143.452.23.719.23a1.248 1.248 0 0 0 .837-.328zm-10.707.116a5.761 5.761 0 0 0 2.212 1.298 1.146 1.146 0 0 0 .857.87 4.602 4.602 0 0 0 1.24 2.222 6.668 6.75 0 0 1-4.31-4.39zm3.327.464c.331 0 .595.263.595.596s-.264.595-.595.595a.59.59 0 0 1-.596-.595.591.591 0 0 1 .596-.596z" />
|
||
</svg>
|
||
</a><a class="VPSocialLink no-icon" href="https://bundlephobia.com/package/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://bundlephobia.com/ -->
|
||
|
||
<svg viewBox="0 0 137 157" xmlns="http://www.w3.org/2000/svg">
|
||
<title>Bundle Phobia</title>
|
||
<g stroke="var(--vp-c-text-2)" stroke-width="1.5" fill="none" fill-rule="evenodd">
|
||
<g transform="translate(37.21 45.73)">
|
||
<rect fill="var(--vp-c-text-2)" x="25.1" y="56.58" width="16.74" height="15.94" rx="7.97"></rect>
|
||
<rect x="25.1" y="40.64" width="16.74" height="31.88" rx="8.37"></rect>
|
||
<ellipse cx="7.13" cy="8.49" rx="7.13" ry="8.45"></ellipse>
|
||
<ellipse cx="56.54" cy="8.49" rx="7.13" ry="8.45"></ellipse>
|
||
</g>
|
||
<g opacity=".40" transform="translate(104.153 25.807)">
|
||
<circle cx="23.51" cy="4.78" r="4.78"></circle>
|
||
<circle cx="6.18" cy="87.47" r="5.92"></circle>
|
||
<path d="M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2"></path>
|
||
</g>
|
||
<path d="M114.1 117.84c1.2-1.02 1.74-1.96 2.48-3.56l19.3-42.92c-2.02-27.1-3.44-40.7-3.44-40.77 0-2.7-2.14-4.8-4.78-4.8-2.6 0-4.73 2.1-4.78 4.7l-3.05 37.7-14.76 42.1c-.44.8-.7 1.8-.7 2.8 0 .83.2 1.64.5 2.4l10.43 40.12 11.55-3.1-12.74-34.8z"></path>
|
||
<path d="M104.97 112.06l10.7 2.98" opacity=".40"></path>
|
||
<g opacity=".40" transform="matrix(-1 0 0 1 33.225 25.807)">
|
||
<circle cx="23.51" cy="4.78" r="4.78"></circle>
|
||
<circle cx="6.18" cy="87.47" r="5.92"></circle>
|
||
<path d="M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2"></path>
|
||
</g>
|
||
<path d="M23.27 117.84c-1.2-1.02-1.73-1.96-2.47-3.56L1.5 71.36c2.02-27.1 3.43-40.7 3.43-40.77 0-2.7 2.14-4.8 4.8-4.8 2.6 0 4.72 2.1 4.77 4.7l3.05 37.7 14.75 42.2c.45.8.7 1.8.7 2.8 0 .8-.18 1.6-.5 2.4l-10.4 40.1-11.55-3.1 12.74-34.8z"></path>
|
||
<path d="M32.4 112.06l-10.7 2.98" opacity=".40"></path>
|
||
<path d="M94.26 91.23c12.2-7.54 20.25-20.38 20.25-34.94 0-3.9-.5-7.6-1.5-11.1C112.8 21 93.2 1.5 68.98 1.5S25 21.02 24.87 45.2c-1.05 3.52-1.6 7.23-1.6 11.05 0 16.54 10.43 30.9 25.6 37.72-.1 1.4-.1 2.82-.1 4.26 0 23.22 10.22 42.04 22.9 42.04 12.65 0 22.92-18.8 22.92-42.03 0-2.4-.2-4.8-.4-7.1z"></path>
|
||
<g opacity=".40" transform="translate(23.263 1.5)">
|
||
<circle cx="45.63" cy="44.03" r="44.03"></circle>
|
||
<ellipse cx="45.63" cy="54.79" rx="45.62" ry="42.04"></ellipse>
|
||
<ellipse cx="48.39" cy="96.83" rx="22.93" ry="42.04"></ellipse>
|
||
</g>
|
||
</g>
|
||
</svg></a><a class="VPSocialLink no-icon" href="https://packagephobia.com/result?p=axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><svg xmlns="http://www.w3.org/2000/svg" width="108" height="108">
|
||
<title>Package Phobia</title>
|
||
<path xmlns="http://www.w3.org/2000/svg" stroke="var(--vp-c-text-2)" style="scale: 18%;" d="M21.667 73.809V33.867l28.33-16.188 28.337 16.188V66.13L49.997 82.321 35 73.75V41.604l14.997-8.57L65 41.604v16.788l-15.003 8.571-1.663-.95v-16.67l8.382-4.792-6.719-3.838-8.33 4.763V69.88l8.33 4.762 21.67-12.383V37.737l-21.67-12.379-21.663 12.379v39.88L49.997 90 85 70V30L49.997 10 15 30v40z" transform="matrix(1.25 0 0 1.25 -8.75 -7.5)"></path>
|
||
</svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-f0dc2006 data-v-eba3bc78 data-v-01e59011><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-01e59011><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="icon" data-v-01e59011><circle cx="12" cy="12" r="2"></circle><circle cx="19" cy="12" r="2"></circle><circle cx="5" cy="12" r="2"></circle></svg></button><div class="menu" data-v-01e59011><div class="VPMenu" data-v-01e59011 data-v-3c10fc56><!----><!--[--><!--[--><!----><div class="group" data-v-eba3bc78><div class="item appearance" data-v-eba3bc78><p class="label" data-v-eba3bc78>Appearance</p><div class="appearance-action" data-v-eba3bc78><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title="toggle dark mode" aria-checked="false" data-v-eba3bc78 data-v-370bd507 data-v-08e8f1e7><span class="check" data-v-08e8f1e7><span class="icon" data-v-08e8f1e7><!--[--><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="sun" data-v-370bd507><path d="M12,18c-3.3,0-6-2.7-6-6s2.7-6,6-6s6,2.7,6,6S15.3,18,12,18zM12,8c-2.2,0-4,1.8-4,4c0,2.2,1.8,4,4,4c2.2,0,4-1.8,4-4C16,9.8,14.2,8,12,8z"></path><path d="M12,4c-0.6,0-1-0.4-1-1V1c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,3.6,12.6,4,12,4z"></path><path d="M12,24c-0.6,0-1-0.4-1-1v-2c0-0.6,0.4-1,1-1s1,0.4,1,1v2C13,23.6,12.6,24,12,24z"></path><path d="M5.6,6.6c-0.3,0-0.5-0.1-0.7-0.3L3.5,4.9c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C6.2,6.5,5.9,6.6,5.6,6.6z"></path><path d="M19.8,20.8c-0.3,0-0.5-0.1-0.7-0.3l-1.4-1.4c-0.4-0.4-0.4-1,0-1.4s1-0.4,1.4,0l1.4,1.4c0.4,0.4,0.4,1,0,1.4C20.3,20.7,20,20.8,19.8,20.8z"></path><path d="M3,13H1c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S3.6,13,3,13z"></path><path d="M23,13h-2c-0.6,0-1-0.4-1-1s0.4-1,1-1h2c0.6,0,1,0.4,1,1S23.6,13,23,13z"></path><path d="M4.2,20.8c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C4.7,20.7,4.5,20.8,4.2,20.8z"></path><path d="M18.4,6.6c-0.3,0-0.5-0.1-0.7-0.3c-0.4-0.4-0.4-1,0-1.4l1.4-1.4c0.4-0.4,1-0.4,1.4,0s0.4,1,0,1.4l-1.4,1.4C18.9,6.5,18.6,6.6,18.4,6.6z"></path></svg><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="moon" data-v-370bd507><path d="M12.1,22c-0.3,0-0.6,0-0.9,0c-5.5-0.5-9.5-5.4-9-10.9c0.4-4.8,4.2-8.6,9-9c0.4,0,0.8,0.2,1,0.5c0.2,0.3,0.2,0.8-0.1,1.1c-2,2.7-1.4,6.4,1.3,8.4c2.1,1.6,5,1.6,7.1,0c0.3-0.2,0.7-0.3,1.1-0.1c0.3,0.2,0.5,0.6,0.5,1c-0.2,2.7-1.5,5.1-3.6,6.8C16.6,21.2,14.4,22,12.1,22zM9.3,4.4c-2.9,1-5,3.6-5.2,6.8c-0.4,4.4,2.8,8.3,7.2,8.7c2.1,0.2,4.2-0.4,5.8-1.8c1.1-0.9,1.9-2.1,2.4-3.4c-2.5,0.9-5.3,0.5-7.5-1.1C9.2,11.4,8.1,7.7,9.3,4.4z"></path></svg><!--]--></span></span></button></div></div></div><div class="group" data-v-eba3bc78><div class="item social-links" data-v-eba3bc78><div class="VPSocialLinks social-links-list" data-v-eba3bc78 data-v-a0caf181><!--[--><a class="VPSocialLink no-icon" href="https://github.com/arthurfiorette/axios-cache-interceptor" aria-label="github" target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>GitHub</title><path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/></svg></a><a class="VPSocialLink no-icon" href="https://npmjs.com/package/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://simpleicons.org/?q=npm -->
|
||
|
||
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0 0 24 24">
|
||
<title>npm</title>
|
||
<path d="M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z" />
|
||
</svg>
|
||
</a><a class="VPSocialLink no-icon" href="https://www.jsdelivr.com/package/npm/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://simpleicons.org/?q=jsdelivr -->
|
||
|
||
<svg xmlns="http://www.w3.org/2000/svg" role="img" viewBox="0 0 24 24">
|
||
<title>jsDelivr</title>
|
||
<path d="M11.851 0L.811 4.02l1.56 14.7L11.85 24l9.6-5.28 1.74-14.76zm.062 4.622a6.668 6.75 0 0 1 2.666.572 12.507 12.507 0 0 0-2.59 1.95c-.045-.02-.092-.031-.138-.045a1.181 1.181 0 0 0-.346-.056c-.071 0-.141.01-.21.021a8.91 8.91 0 0 1-.615-2.318 6.668 6.75 0 0 1 1.171-.122 6.668 6.75 0 0 1 .062-.002zm-1.99.312a9.763 9.763 0 0 0 .69 2.504 1.213 1.213 0 0 0-.328.825 1.202 1.202 0 0 0 .18.63c-.937 1.294-1.656 2.803-1.905 4.31-.01.056-.013.11-.02.166-.282.09-.515.284-.656.54-.987-.333-1.885-.968-2.615-2.022a6.668 6.75 0 0 1-.026-.515 6.668 6.75 0 0 1 4.68-6.438zm5.507.709a6.668 6.75 0 0 1 2.53 2.9c-.377.953-1.049 1.892-1.893 2.727a1.242 1.242 0 0 0-.644-.184 1.243 1.243 0 0 0-.768.27c-.462-.354-.91-.737-1.318-1.168-.333-.35-.637-.73-.921-1.123.19-.215.31-.494.31-.802 0-.212-.061-.41-.159-.586 1.058-1.008 2.112-1.67 2.863-2.034zm-3.925 1.982a.624.624 0 0 1 .346.114.624.624 0 0 1 .292.524.624.624 0 0 1-.292.524.626.626 0 0 1-.346.113.634.634 0 0 1-.638-.637c0-.355.283-.638.638-.638zm-.441 1.771a1.205 1.205 0 0 0 .675.062c.036.05.075.097.112.148a11.438 11.438 0 0 0 .921 1.119 12.103 12.103 0 0 0 1.446 1.277c-.032.11-.054.224-.054.342a1.236 1.236 0 0 0 .066.38 9.91 9.91 0 0 1-2.118 1.042c-.087.029-.173.052-.261.078a7.735 7.735 0 0 1-1.87.332 1.15 1.15 0 0 0-.66-.773c.004-.024.005-.049.01-.073.219-1.333.873-2.73 1.733-3.934zm7.272.19a6.668 6.75 0 0 1 .245 1.786 6.668 6.75 0 0 1-.259 1.856 9.993 9.993 0 0 1-1.666-.63 1.243 1.243 0 0 0-.065-.713 9.434 9.434 0 0 0 1.745-2.3zm-2.913 2.101c.367 0 .657.291.657.658s-.291.657-.657.657c-.367 0-.658-.29-.658-.657s.29-.658.658-.658zm.837 1.59a10.79 10.79 0 0 0 1.802.688 6.668 6.75 0 0 1-6.149 4.157 6.668 6.75 0 0 1-.062-.004 6.668 6.75 0 0 1-.042 0c-.087-.042-.168-.08-.266-.129-.312-.154-.667-.352-.846-.5a3.796 3.796 0 0 1-1.294-2.03c.21-.111.38-.284.487-.495a8.428 8.428 0 0 0 1.96-.306 9.11 9.11 0 0 0 .513-.154 11.083 11.083 0 0 0 2.341-1.13c.205.143.452.23.719.23a1.248 1.248 0 0 0 .837-.328zm-10.707.116a5.761 5.761 0 0 0 2.212 1.298 1.146 1.146 0 0 0 .857.87 4.602 4.602 0 0 0 1.24 2.222 6.668 6.75 0 0 1-4.31-4.39zm3.327.464c.331 0 .595.263.595.596s-.264.595-.595.595a.59.59 0 0 1-.596-.595.591.591 0 0 1 .596-.596z" />
|
||
</svg>
|
||
</a><a class="VPSocialLink no-icon" href="https://bundlephobia.com/package/axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><!-- https://bundlephobia.com/ -->
|
||
|
||
<svg viewBox="0 0 137 157" xmlns="http://www.w3.org/2000/svg">
|
||
<title>Bundle Phobia</title>
|
||
<g stroke="var(--vp-c-text-2)" stroke-width="1.5" fill="none" fill-rule="evenodd">
|
||
<g transform="translate(37.21 45.73)">
|
||
<rect fill="var(--vp-c-text-2)" x="25.1" y="56.58" width="16.74" height="15.94" rx="7.97"></rect>
|
||
<rect x="25.1" y="40.64" width="16.74" height="31.88" rx="8.37"></rect>
|
||
<ellipse cx="7.13" cy="8.49" rx="7.13" ry="8.45"></ellipse>
|
||
<ellipse cx="56.54" cy="8.49" rx="7.13" ry="8.45"></ellipse>
|
||
</g>
|
||
<g opacity=".40" transform="translate(104.153 25.807)">
|
||
<circle cx="23.51" cy="4.78" r="4.78"></circle>
|
||
<circle cx="6.18" cy="87.47" r="5.92"></circle>
|
||
<path d="M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2"></path>
|
||
</g>
|
||
<path d="M114.1 117.84c1.2-1.02 1.74-1.96 2.48-3.56l19.3-42.92c-2.02-27.1-3.44-40.7-3.44-40.77 0-2.7-2.14-4.8-4.78-4.8-2.6 0-4.73 2.1-4.78 4.7l-3.05 37.7-14.76 42.1c-.44.8-.7 1.8-.7 2.8 0 .83.2 1.64.5 2.4l10.43 40.12 11.55-3.1-12.74-34.8z"></path>
|
||
<path d="M104.97 112.06l10.7 2.98" opacity=".40"></path>
|
||
<g opacity=".40" transform="matrix(-1 0 0 1 33.225 25.807)">
|
||
<circle cx="23.51" cy="4.78" r="4.78"></circle>
|
||
<circle cx="6.18" cy="87.47" r="5.92"></circle>
|
||
<path d="M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2"></path>
|
||
</g>
|
||
<path d="M23.27 117.84c-1.2-1.02-1.73-1.96-2.47-3.56L1.5 71.36c2.02-27.1 3.43-40.7 3.43-40.77 0-2.7 2.14-4.8 4.8-4.8 2.6 0 4.72 2.1 4.77 4.7l3.05 37.7 14.75 42.2c.45.8.7 1.8.7 2.8 0 .8-.18 1.6-.5 2.4l-10.4 40.1-11.55-3.1 12.74-34.8z"></path>
|
||
<path d="M32.4 112.06l-10.7 2.98" opacity=".40"></path>
|
||
<path d="M94.26 91.23c12.2-7.54 20.25-20.38 20.25-34.94 0-3.9-.5-7.6-1.5-11.1C112.8 21 93.2 1.5 68.98 1.5S25 21.02 24.87 45.2c-1.05 3.52-1.6 7.23-1.6 11.05 0 16.54 10.43 30.9 25.6 37.72-.1 1.4-.1 2.82-.1 4.26 0 23.22 10.22 42.04 22.9 42.04 12.65 0 22.92-18.8 22.92-42.03 0-2.4-.2-4.8-.4-7.1z"></path>
|
||
<g opacity=".40" transform="translate(23.263 1.5)">
|
||
<circle cx="45.63" cy="44.03" r="44.03"></circle>
|
||
<ellipse cx="45.63" cy="54.79" rx="45.62" ry="42.04"></ellipse>
|
||
<ellipse cx="48.39" cy="96.83" rx="22.93" ry="42.04"></ellipse>
|
||
</g>
|
||
</g>
|
||
</svg></a><a class="VPSocialLink no-icon" href="https://packagephobia.com/result?p=axios-cache-interceptor" aria-label target="_blank" rel="noopener" data-v-a0caf181 data-v-9e1d5446><svg xmlns="http://www.w3.org/2000/svg" width="108" height="108">
|
||
<title>Package Phobia</title>
|
||
<path xmlns="http://www.w3.org/2000/svg" stroke="var(--vp-c-text-2)" style="scale: 18%;" d="M21.667 73.809V33.867l28.33-16.188 28.337 16.188V66.13L49.997 82.321 35 73.75V41.604l14.997-8.57L65 41.604v16.788l-15.003 8.571-1.663-.95v-16.67l8.382-4.792-6.719-3.838-8.33 4.763V69.88l8.33 4.762 21.67-12.383V37.737l-21.67-12.379-21.663 12.379v39.88L49.997 90 85 70V30L49.997 10 15 30v40z" transform="matrix(1.25 0 0 1.25 -8.75 -7.5)"></path>
|
||
</svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-f0dc2006 data-v-b15b59b4><span class="container" data-v-b15b59b4><span class="top" data-v-b15b59b4></span><span class="middle" data-v-b15b59b4></span><span class="bottom" data-v-b15b59b4></span></span></button></div></div></div></div><!----></header><div class="VPLocalNav reached-top" data-v-721252dc data-v-44b6bd0d><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-44b6bd0d><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" viewbox="0 0 24 24" class="menu-icon" data-v-44b6bd0d><path d="M17,11H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,11,17,11z"></path><path d="M21,7H3C2.4,7,2,6.6,2,6s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,7,21,7z"></path><path d="M21,15H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h18c0.6,0,1,0.4,1,1S21.6,15,21,15z"></path><path d="M17,19H3c-0.6,0-1-0.4-1-1s0.4-1,1-1h14c0.6,0,1,0.4,1,1S17.6,19,17,19z"></path></svg><span class="menu-text" data-v-44b6bd0d>Menu</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-44b6bd0d data-v-8906a1a4><button data-v-8906a1a4>Return to top</button><!----></div></div><aside class="VPSidebar" data-v-721252dc data-v-5af88cc9><div class="curtain" data-v-5af88cc9></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-5af88cc9><span class="visually-hidden" id="sidebar-aria-label" data-v-5af88cc9> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="group" data-v-5af88cc9><section class="VPSidebarItem level-0 has-active" data-v-5af88cc9 data-v-be60c292><div class="item" role="button" tabindex="0" data-v-be60c292><div class="indicator" data-v-be60c292></div><h2 class="text" data-v-be60c292>Guide</h2><!----></div><div class="items" data-v-be60c292><!--[--><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Introduction</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/getting-started" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Getting Started</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/debugging" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Debugging</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/storages" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Storages</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/request-id" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Request Id</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/invalidating-cache" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Invalidating Cache</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/comparison" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Comparison</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/guide/interceptors" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Other Interceptors</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-5af88cc9><section class="VPSidebarItem level-0" data-v-5af88cc9 data-v-be60c292><div class="item" role="button" tabindex="0" data-v-be60c292><div class="indicator" data-v-be60c292></div><h2 class="text" data-v-be60c292>Config</h2><!----></div><div class="items" data-v-be60c292><!--[--><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/config" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Global Configuration</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/config/request-specifics" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Request Specifics</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/config/response-object" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Response Object</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="group" data-v-5af88cc9><section class="VPSidebarItem level-0" data-v-5af88cc9 data-v-be60c292><div class="item" role="button" tabindex="0" data-v-be60c292><div class="indicator" data-v-be60c292></div><h2 class="text" data-v-be60c292>Others</h2><!----></div><div class="items" data-v-be60c292><!--[--><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/others/license" data-v-be60c292><!--[--><p class="text" data-v-be60c292>MIT License</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-be60c292 data-v-be60c292><div class="item" data-v-be60c292><div class="indicator" data-v-be60c292></div><a class="VPLink link link" href="/others/changelog" data-v-be60c292><!--[--><p class="text" data-v-be60c292>Changelog</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-721252dc data-v-36902160><div class="VPDoc has-sidebar has-aside" data-v-36902160 data-v-1217bee5><!--[--><!--]--><div class="container" data-v-1217bee5><div class="aside" data-v-1217bee5><div class="aside-curtain" data-v-1217bee5></div><div class="aside-container" data-v-1217bee5><div class="aside-content" data-v-1217bee5><div class="VPDocAside" data-v-1217bee5 data-v-47140c8b><!--[--><!--]--><!--[--><!--]--><div class="VPDocAsideOutline" role="navigation" data-v-47140c8b data-v-27133afe><div class="content" data-v-27133afe><div class="outline-marker" data-v-27133afe></div><div class="outline-title" role="heading" aria-level="2" data-v-27133afe>On this page</div><nav aria-labelledby="doc-outline-aria-label" data-v-27133afe><span class="visually-hidden" id="doc-outline-aria-label" data-v-27133afe> Table of Contents for current page </span><ul class="root" data-v-27133afe data-v-d37ec511><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><div class="spacer" data-v-47140c8b></div><!--[--><!--]--><div class="VPDocAsideCarbonAds" data-v-47140c8b><div class="VPCarbonAds" data-v-303c804b></div></div><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-1217bee5><div class="content-container" data-v-1217bee5><!--[--><!--]--><!----><main class="main" data-v-1217bee5><div style="position:relative;" class="vp-doc _guide_invalidating-cache" data-v-1217bee5><div><h1 id="invalidating-cache" tabindex="-1">Invalidating Cache <a class="header-anchor" href="#invalidating-cache" aria-label="Permalink to "Invalidating Cache""></a></h1><p>When using cache-first approaches to improve performance, data inconsistency becomes your major problem. That occurs because <strong>you</strong> can mutate data in the server and <strong>others</strong> also can too. Becoming impossible to really know what is the current state of the data at real time without communicating with the server.</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p><strong>All available revalidation methods only works when the request is successful.</strong></p><p>If you are wanting to revalidate with a non standard <code>2XX</code> status code, make sure to enable it at <a href="https://axios-http.com/docs/handling_errors" target="_blank" rel="noreferrer"><code>validateStatus</code></a> or revalidate it manually as shown <a href="#updating-cache-through-external-sources">below</a>.</p></div><p>Take a look at this simple example:</p><ol><li>User list all available posts, server return an empty array.</li><li>User proceeds to create a new post, server returns 200 OK.</li><li>Your frontend navigates to the post list page.</li><li>The post list page still shows 0 posts because it had a recent cache for that request.</li><li>Your client shows 0 posts, but the server actually has 1 post.</li></ol><h2 id="revalidation-after-mutation" tabindex="-1">Revalidation after mutation <a class="header-anchor" href="#revalidation-after-mutation" aria-label="Permalink to "Revalidation after mutation""></a></h2><p>Most of the cases, you were the one responsible for that inconsistency, like in the above example when the client himself initiated the mutation request. When that happens, you are capable of invalidating the cache for all places you have changed too.</p><p><strong>The <code>cache.update</code> option is available for every request that you make, and it will be the go-to tool for invalidation.</strong></p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>By centralizing your requests into separate methods, you are more likely to keep track of custom IDs you use for each request, thus making it easier to reference and invalidate after.</p></div><h2 id="programmatically" tabindex="-1">Programmatically <a class="header-anchor" href="#programmatically" aria-label="Permalink to "Programmatically""></a></h2><p>If the mutation you made was just simple changes, you can get the mutation response and update programmatically your cache.</p><p>Again considering the first example, we can just to an <code>array.push</code> to the <code>list-posts</code> cache and we are good to go.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark has-focused-lines vp-code-dark"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">listPosts</span><span style="color:#E1E4E8;">() {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">get</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">, {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> id: </span><span style="color:#9ECBFF;">'list-posts'</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> });</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">createPost</span><span style="color:#E1E4E8;">(</span><span style="color:#FFAB70;">data</span><span style="color:#E1E4E8;">) {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">post</span><span style="color:#E1E4E8;">(</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> data,</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> cache: {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> update: {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Will perform a cache update for the `list-posts` respective</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// cache entry.</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'list-posts'</span><span style="color:#E1E4E8;">: (</span><span style="color:#FFAB70;">listPostsCache</span><span style="color:#E1E4E8;">, </span><span style="color:#FFAB70;">createPostResponse</span><span style="color:#E1E4E8;">) </span><span style="color:#F97583;">=></span><span style="color:#E1E4E8;"> {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// If the cache is does not has a cached state, we don't need</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// to update it</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">if</span><span style="color:#E1E4E8;"> (listPostsCache.state </span><span style="color:#F97583;">!==</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'cached'</span><span style="color:#E1E4E8;">) {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'ignore'</span><span style="color:#E1E4E8;">;</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Imagine the server response for the `list-posts` request</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// is: { posts: Post[]; }, and the `create-post` response</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// comes with the newly created post.</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Adds the created post to the end of the post's list</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> listPostsCache.data.posts.</span><span style="color:#B392F0;">push</span><span style="color:#E1E4E8;">(createPostResponse.data);</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Return the same cache state, but a updated one.</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> listPostsCache;</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> );</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light has-focused-lines vp-code-light"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">listPosts</span><span style="color:#24292E;">() {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">get</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">, {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> id: </span><span style="color:#032F62;">'list-posts'</span></span>
|
||
<span class="line"><span style="color:#24292E;"> });</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">createPost</span><span style="color:#24292E;">(</span><span style="color:#E36209;">data</span><span style="color:#24292E;">) {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">post</span><span style="color:#24292E;">(</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">,</span></span>
|
||
<span class="line"><span style="color:#24292E;"> data,</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> cache: {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> update: {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Will perform a cache update for the `list-posts` respective</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// cache entry.</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#032F62;">'list-posts'</span><span style="color:#24292E;">: (</span><span style="color:#E36209;">listPostsCache</span><span style="color:#24292E;">, </span><span style="color:#E36209;">createPostResponse</span><span style="color:#24292E;">) </span><span style="color:#D73A49;">=></span><span style="color:#24292E;"> {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// If the cache is does not has a cached state, we don't need</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// to update it</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#D73A49;">if</span><span style="color:#24292E;"> (listPostsCache.state </span><span style="color:#D73A49;">!==</span><span style="color:#24292E;"> </span><span style="color:#032F62;">'cached'</span><span style="color:#24292E;">) {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> </span><span style="color:#032F62;">'ignore'</span><span style="color:#24292E;">;</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Imagine the server response for the `list-posts` request</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// is: { posts: Post[]; }, and the `create-post` response</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// comes with the newly created post.</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Adds the created post to the end of the post's list</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> listPostsCache.data.posts.</span><span style="color:#6F42C1;">push</span><span style="color:#24292E;">(createPostResponse.data);</span></span>
|
||
<span class="line has-focus"></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Return the same cache state, but a updated one.</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> listPostsCache;</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line"><span style="color:#24292E;"> );</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><p>This will update the <code>list-posts</code> cache at the client side, making it equal to the server. When operations like this are possible to be made, they are the preferred. That’s because we do not contact the server again and update ourselves the cache.</p><h2 id="through-network" tabindex="-1">Through network <a class="header-anchor" href="#through-network" aria-label="Permalink to "Through network""></a></h2><p>Sometimes, the mutation you made is not simple enough and would need a lot of copied service code to replicate all changes the backend made, turning it into a duplication and maintenance nightmare.</p><p>In those cases, you can just invalidate the cache and let the next request be forwarded to the server, and updating the cache with the new network response.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark has-focused-lines vp-code-dark"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">listPosts</span><span style="color:#E1E4E8;">() {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">get</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">, {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> id: </span><span style="color:#9ECBFF;">'list-posts'</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> });</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">createPost</span><span style="color:#E1E4E8;">(</span><span style="color:#FFAB70;">data</span><span style="color:#E1E4E8;">) {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">post</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">, data, {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> cache: {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> update: {</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Will, internally, call storage.remove('list-posts') and let the</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// next request be forwarded to the server without you having to</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// do any checks.</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'list-posts'</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">'delete'</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> });</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light has-focused-lines vp-code-light"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">listPosts</span><span style="color:#24292E;">() {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">get</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">, {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> id: </span><span style="color:#032F62;">'list-posts'</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> });</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">createPost</span><span style="color:#24292E;">(</span><span style="color:#E36209;">data</span><span style="color:#24292E;">) {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">post</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">, data, {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> cache: {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> update: {</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Will, internally, call storage.remove('list-posts') and let the</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// next request be forwarded to the server without you having to</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// do any checks.</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> </span><span style="color:#032F62;">'list-posts'</span><span style="color:#24292E;">: </span><span style="color:#032F62;">'delete'</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line has-focus"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line"><span style="color:#24292E;"> });</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><p>Still using the first example, while we are at the step <strong>3</strong>, automatically, the-axios cache-interceptor instance will request the server again and do required changes in the cache before the promise resolves and your page gets rendered.</p><h2 id="through-external-sources" tabindex="-1">Through external sources <a class="header-anchor" href="#through-external-sources" aria-label="Permalink to "Through external sources""></a></h2><p>If you have any other type of external communication, like when listening to a websocket for changes, you may want to update your axios cache without be in a request context.</p><p>For that, you can operate the storage manually. It is simple as that:</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#F97583;">if</span><span style="color:#E1E4E8;"> (someLogicThatShowsIfTheCacheShouldBeInvalidated) {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// Deletes the current cache for the `list-posts` respective request.</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">await</span><span style="color:#E1E4E8;"> axios.storage.</span><span style="color:#B392F0;">remove</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'list-posts'</span><span style="color:#E1E4E8;">);</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#D73A49;">if</span><span style="color:#24292E;"> (someLogicThatShowsIfTheCacheShouldBeInvalidated) {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// Deletes the current cache for the `list-posts` respective request.</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">await</span><span style="color:#24292E;"> axios.storage.</span><span style="color:#6F42C1;">remove</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'list-posts'</span><span style="color:#24292E;">);</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><h2 id="keeping-cache-up-to-date" tabindex="-1">Keeping cache up to date <a class="header-anchor" href="#keeping-cache-up-to-date" aria-label="Permalink to "Keeping cache up to date""></a></h2><p>If you were <strong>not</strong> the one responsible for that change, your client may not be aware that it has changed. E.g. When you are using a chat application, you may not be aware that a new message was sent to you.</p><p>In such cases that we do have a way to know that the cache is outdated, you may have to end up setting a custom time to live (TTL) for specific requests.</p><div class="language-ts vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki github-dark vp-code-dark"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">listPosts</span><span style="color:#E1E4E8;">() {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">get</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">, {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> id: </span><span style="color:#9ECBFF;">'list-posts'</span><span style="color:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> cache: {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> ttl: </span><span style="color:#79B8FF;">1000</span><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">*</span><span style="color:#E1E4E8;"> </span><span style="color:#79B8FF;">60</span><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// 1 minute.</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> });</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#F97583;">function</span><span style="color:#E1E4E8;"> </span><span style="color:#B392F0;">createPost</span><span style="color:#E1E4E8;">(</span><span style="color:#FFAB70;">data</span><span style="color:#E1E4E8;">) {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#F97583;">return</span><span style="color:#E1E4E8;"> axios.</span><span style="color:#B392F0;">post</span><span style="color:#E1E4E8;">(</span><span style="color:#9ECBFF;">'/posts'</span><span style="color:#E1E4E8;">, data, {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> cache: {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> update: {</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// I still want to delete the cache when I KNOW things have</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// changed, but, by setting a TTL of 1 minute, I ensure that</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// 1 minute is the highest time interval that the cache MAY</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#6A737D;">// get outdated.</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> </span><span style="color:#9ECBFF;">'list-posts'</span><span style="color:#E1E4E8;">: </span><span style="color:#9ECBFF;">'delete'</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> }</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;"> });</span></span>
|
||
<span class="line"><span style="color:#E1E4E8;">}</span></span></code></pre><pre class="shiki github-light vp-code-light"><code><span class="line"><span style="color:#6A737D;">// Uses `list-posts` id to be able to reference it later.</span></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">listPosts</span><span style="color:#24292E;">() {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">get</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">, {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> id: </span><span style="color:#032F62;">'list-posts'</span><span style="color:#24292E;">,</span></span>
|
||
<span class="line"><span style="color:#24292E;"> cache: {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> ttl: </span><span style="color:#005CC5;">1000</span><span style="color:#24292E;"> </span><span style="color:#D73A49;">*</span><span style="color:#24292E;"> </span><span style="color:#005CC5;">60</span><span style="color:#24292E;"> </span><span style="color:#6A737D;">// 1 minute.</span></span>
|
||
<span class="line"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line"><span style="color:#24292E;"> });</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span>
|
||
<span class="line"></span>
|
||
<span class="line"><span style="color:#D73A49;">function</span><span style="color:#24292E;"> </span><span style="color:#6F42C1;">createPost</span><span style="color:#24292E;">(</span><span style="color:#E36209;">data</span><span style="color:#24292E;">) {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#D73A49;">return</span><span style="color:#24292E;"> axios.</span><span style="color:#6F42C1;">post</span><span style="color:#24292E;">(</span><span style="color:#032F62;">'/posts'</span><span style="color:#24292E;">, data, {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> cache: {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> update: {</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// I still want to delete the cache when I KNOW things have</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// changed, but, by setting a TTL of 1 minute, I ensure that</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// 1 minute is the highest time interval that the cache MAY</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#6A737D;">// get outdated.</span></span>
|
||
<span class="line"><span style="color:#24292E;"> </span><span style="color:#032F62;">'list-posts'</span><span style="color:#24292E;">: </span><span style="color:#032F62;">'delete'</span></span>
|
||
<span class="line"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line"><span style="color:#24292E;"> }</span></span>
|
||
<span class="line"><span style="color:#24292E;"> });</span></span>
|
||
<span class="line"><span style="color:#24292E;">}</span></span></code></pre></div><h2 id="summing-up" tabindex="-1">Summing up <a class="header-anchor" href="#summing-up" aria-label="Permalink to "Summing up""></a></h2><p>When applying any kind of cache to any kind of application, you chose to trade data consistency for performance. And, most of the time that is OK.</p><p><em>The best cache strategy is a combination of all of them. TTL, custom revalidation, stale while revalidate and all the others together are the best solution.</em></p><p>The only real tip here is to you put on a scale the amount of inconsistency you are willing to give up for the performance you are willing to gain. <strong>Sometimes, not caching is the best solution.</strong></p></div></div></main><footer class="VPDocFooter" data-v-1217bee5 data-v-869a3c2b><!--[--><!--]--><div class="edit-info" data-v-869a3c2b><div class="edit-link" data-v-869a3c2b><a class="VPLink link vp-external-link-icon no-icon edit-link-button" href="https://github.com/arthurfiorette/axios-cache-interceptor/edit/main/docs/src/guide/invalidating-cache.md" target="_blank" rel="noreferrer" data-v-869a3c2b><!--[--><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 24 24" class="edit-link-icon" aria-label="edit icon" data-v-869a3c2b><path d="M18,23H4c-1.7,0-3-1.3-3-3V6c0-1.7,1.3-3,3-3h7c0.6,0,1,0.4,1,1s-0.4,1-1,1H4C3.4,5,3,5.4,3,6v14c0,0.6,0.4,1,1,1h14c0.6,0,1-0.4,1-1v-7c0-0.6,0.4-1,1-1s1,0.4,1,1v7C21,21.7,19.7,23,18,23z"></path><path d="M8,17c-0.3,0-0.5-0.1-0.7-0.3C7,16.5,6.9,16.1,7,15.8l1-4c0-0.2,0.1-0.3,0.3-0.5l9.5-9.5c1.2-1.2,3.2-1.2,4.4,0c1.2,1.2,1.2,3.2,0,4.4l-9.5,9.5c-0.1,0.1-0.3,0.2-0.5,0.3l-4,1C8.2,17,8.1,17,8,17zM9.9,12.5l-0.5,2.1l2.1-0.5l9.3-9.3c0.4-0.4,0.4-1.1,0-1.6c-0.4-0.4-1.2-0.4-1.6,0l0,0L9.9,12.5z M18.5,2.5L18.5,2.5L18.5,2.5z"></path></svg> Edit this page<!--]--></a></div><div class="last-updated" data-v-869a3c2b><p class="VPLastUpdated" data-v-869a3c2b data-v-e23ea019>Last updated: <time datetime="2023-10-13T08:15:24.000Z" data-v-e23ea019></time></p></div></div><nav class="prev-next" data-v-869a3c2b><div class="pager" data-v-869a3c2b><a class="pager-link prev" href="/guide/request-id" data-v-869a3c2b><span class="desc" data-v-869a3c2b>Previous page</span><span class="title" data-v-869a3c2b>Request Id</span></a></div><div class="pager" data-v-869a3c2b><a class="pager-link next" href="/guide/comparison" data-v-869a3c2b><span class="desc" data-v-869a3c2b>Next page</span><span class="title" data-v-869a3c2b>Comparison</span></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-721252dc data-v-77c28549><div class="container" data-v-77c28549><p class="message" data-v-77c28549>Made with ❤️</p><p class="copyright" data-v-77c28549>Copyright (c) 2021-present Arthur Fiorette & Contributors</p></div></footer><!--[--><!--]--></div></div>
|
||
<script>window.__VP_HASH_MAP__=JSON.parse("{\"guide_debugging.md\":\"6974b57e\",\"guide_invalidating-cache.md\":\"2c8f5834\",\"index.md\":\"92427f74\",\"config_response-object.md\":\"3a44d9f5\",\"guide.md\":\"56e500e9\",\"guide_comparison.md\":\"00198bff\",\"guide_getting-started.md\":\"272d0aa9\",\"guide_interceptors.md\":\"3a630ca4\",\"config_request-specifics.md\":\"929e3890\",\"guide_request-id.md\":\"316c03da\",\"config.md\":\"7f1bcdcb\",\"guide_storages.md\":\"590c1f2f\",\"others_license.md\":\"656382f8\",\"generated_benchmark.md\":\"a3d2fba7\",\"others_changelog.md\":\"e82dc6c0\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"Axios Cache Interceptor\",\"description\":\"Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!\",\"base\":\"/\",\"head\":[],\"appearance\":true,\"themeConfig\":{\"socialLinks\":[{\"icon\":\"github\",\"link\":\"https://github.com/arthurfiorette/axios-cache-interceptor\"},{\"icon\":{\"svg\":\"<!-- https://simpleicons.org/?q=npm -->\\n\\n<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" role=\\\"img\\\" viewBox=\\\"0 0 24 24\\\">\\n <title>npm</title>\\n <path d=\\\"M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z\\\" />\\n</svg>\\n\"},\"link\":\"https://npmjs.com/package/axios-cache-interceptor\"},{\"icon\":{\"svg\":\"<!-- https://simpleicons.org/?q=jsdelivr -->\\n\\n<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" role=\\\"img\\\" viewBox=\\\"0 0 24 24\\\">\\n <title>jsDelivr</title>\\n <path d=\\\"M11.851 0L.811 4.02l1.56 14.7L11.85 24l9.6-5.28 1.74-14.76zm.062 4.622a6.668 6.75 0 0 1 2.666.572 12.507 12.507 0 0 0-2.59 1.95c-.045-.02-.092-.031-.138-.045a1.181 1.181 0 0 0-.346-.056c-.071 0-.141.01-.21.021a8.91 8.91 0 0 1-.615-2.318 6.668 6.75 0 0 1 1.171-.122 6.668 6.75 0 0 1 .062-.002zm-1.99.312a9.763 9.763 0 0 0 .69 2.504 1.213 1.213 0 0 0-.328.825 1.202 1.202 0 0 0 .18.63c-.937 1.294-1.656 2.803-1.905 4.31-.01.056-.013.11-.02.166-.282.09-.515.284-.656.54-.987-.333-1.885-.968-2.615-2.022a6.668 6.75 0 0 1-.026-.515 6.668 6.75 0 0 1 4.68-6.438zm5.507.709a6.668 6.75 0 0 1 2.53 2.9c-.377.953-1.049 1.892-1.893 2.727a1.242 1.242 0 0 0-.644-.184 1.243 1.243 0 0 0-.768.27c-.462-.354-.91-.737-1.318-1.168-.333-.35-.637-.73-.921-1.123.19-.215.31-.494.31-.802 0-.212-.061-.41-.159-.586 1.058-1.008 2.112-1.67 2.863-2.034zm-3.925 1.982a.624.624 0 0 1 .346.114.624.624 0 0 1 .292.524.624.624 0 0 1-.292.524.626.626 0 0 1-.346.113.634.634 0 0 1-.638-.637c0-.355.283-.638.638-.638zm-.441 1.771a1.205 1.205 0 0 0 .675.062c.036.05.075.097.112.148a11.438 11.438 0 0 0 .921 1.119 12.103 12.103 0 0 0 1.446 1.277c-.032.11-.054.224-.054.342a1.236 1.236 0 0 0 .066.38 9.91 9.91 0 0 1-2.118 1.042c-.087.029-.173.052-.261.078a7.735 7.735 0 0 1-1.87.332 1.15 1.15 0 0 0-.66-.773c.004-.024.005-.049.01-.073.219-1.333.873-2.73 1.733-3.934zm7.272.19a6.668 6.75 0 0 1 .245 1.786 6.668 6.75 0 0 1-.259 1.856 9.993 9.993 0 0 1-1.666-.63 1.243 1.243 0 0 0-.065-.713 9.434 9.434 0 0 0 1.745-2.3zm-2.913 2.101c.367 0 .657.291.657.658s-.291.657-.657.657c-.367 0-.658-.29-.658-.657s.29-.658.658-.658zm.837 1.59a10.79 10.79 0 0 0 1.802.688 6.668 6.75 0 0 1-6.149 4.157 6.668 6.75 0 0 1-.062-.004 6.668 6.75 0 0 1-.042 0c-.087-.042-.168-.08-.266-.129-.312-.154-.667-.352-.846-.5a3.796 3.796 0 0 1-1.294-2.03c.21-.111.38-.284.487-.495a8.428 8.428 0 0 0 1.96-.306 9.11 9.11 0 0 0 .513-.154 11.083 11.083 0 0 0 2.341-1.13c.205.143.452.23.719.23a1.248 1.248 0 0 0 .837-.328zm-10.707.116a5.761 5.761 0 0 0 2.212 1.298 1.146 1.146 0 0 0 .857.87 4.602 4.602 0 0 0 1.24 2.222 6.668 6.75 0 0 1-4.31-4.39zm3.327.464c.331 0 .595.263.595.596s-.264.595-.595.595a.59.59 0 0 1-.596-.595.591.591 0 0 1 .596-.596z\\\" />\\n</svg>\\n\"},\"link\":\"https://www.jsdelivr.com/package/npm/axios-cache-interceptor\"},{\"icon\":{\"svg\":\"<!-- https://bundlephobia.com/ -->\\n\\n<svg viewBox=\\\"0 0 137 157\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\">\\n <title>Bundle Phobia</title>\\n <g stroke=\\\"var(--vp-c-text-2)\\\" stroke-width=\\\"1.5\\\" fill=\\\"none\\\" fill-rule=\\\"evenodd\\\">\\n <g transform=\\\"translate(37.21 45.73)\\\">\\n <rect fill=\\\"var(--vp-c-text-2)\\\" x=\\\"25.1\\\" y=\\\"56.58\\\" width=\\\"16.74\\\" height=\\\"15.94\\\" rx=\\\"7.97\\\"></rect>\\n <rect x=\\\"25.1\\\" y=\\\"40.64\\\" width=\\\"16.74\\\" height=\\\"31.88\\\" rx=\\\"8.37\\\"></rect>\\n <ellipse cx=\\\"7.13\\\" cy=\\\"8.49\\\" rx=\\\"7.13\\\" ry=\\\"8.45\\\"></ellipse>\\n <ellipse cx=\\\"56.54\\\" cy=\\\"8.49\\\" rx=\\\"7.13\\\" ry=\\\"8.45\\\"></ellipse>\\n </g>\\n <g opacity=\\\".40\\\" transform=\\\"translate(104.153 25.807)\\\">\\n <circle cx=\\\"23.51\\\" cy=\\\"4.78\\\" r=\\\"4.78\\\"></circle>\\n <circle cx=\\\"6.18\\\" cy=\\\"87.47\\\" r=\\\"5.92\\\"></circle>\\n <path d=\\\"M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2\\\"></path>\\n </g>\\n <path d=\\\"M114.1 117.84c1.2-1.02 1.74-1.96 2.48-3.56l19.3-42.92c-2.02-27.1-3.44-40.7-3.44-40.77 0-2.7-2.14-4.8-4.78-4.8-2.6 0-4.73 2.1-4.78 4.7l-3.05 37.7-14.76 42.1c-.44.8-.7 1.8-.7 2.8 0 .83.2 1.64.5 2.4l10.43 40.12 11.55-3.1-12.74-34.8z\\\"></path>\\n <path d=\\\"M104.97 112.06l10.7 2.98\\\" opacity=\\\".40\\\"></path>\\n <g opacity=\\\".40\\\" transform=\\\"matrix(-1 0 0 1 33.225 25.807)\\\">\\n <circle cx=\\\"23.51\\\" cy=\\\"4.78\\\" r=\\\"4.78\\\"></circle>\\n <circle cx=\\\"6.18\\\" cy=\\\"87.47\\\" r=\\\"5.92\\\"></circle>\\n <path d=\\\"M18.3 4.7l9.55.16m3.52 41.16L15 45.54m1.22-7.7L31.7 45.2\\\"></path>\\n </g>\\n <path d=\\\"M23.27 117.84c-1.2-1.02-1.73-1.96-2.47-3.56L1.5 71.36c2.02-27.1 3.43-40.7 3.43-40.77 0-2.7 2.14-4.8 4.8-4.8 2.6 0 4.72 2.1 4.77 4.7l3.05 37.7 14.75 42.2c.45.8.7 1.8.7 2.8 0 .8-.18 1.6-.5 2.4l-10.4 40.1-11.55-3.1 12.74-34.8z\\\"></path>\\n <path d=\\\"M32.4 112.06l-10.7 2.98\\\" opacity=\\\".40\\\"></path>\\n <path d=\\\"M94.26 91.23c12.2-7.54 20.25-20.38 20.25-34.94 0-3.9-.5-7.6-1.5-11.1C112.8 21 93.2 1.5 68.98 1.5S25 21.02 24.87 45.2c-1.05 3.52-1.6 7.23-1.6 11.05 0 16.54 10.43 30.9 25.6 37.72-.1 1.4-.1 2.82-.1 4.26 0 23.22 10.22 42.04 22.9 42.04 12.65 0 22.92-18.8 22.92-42.03 0-2.4-.2-4.8-.4-7.1z\\\"></path>\\n <g opacity=\\\".40\\\" transform=\\\"translate(23.263 1.5)\\\">\\n <circle cx=\\\"45.63\\\" cy=\\\"44.03\\\" r=\\\"44.03\\\"></circle>\\n <ellipse cx=\\\"45.63\\\" cy=\\\"54.79\\\" rx=\\\"45.62\\\" ry=\\\"42.04\\\"></ellipse>\\n <ellipse cx=\\\"48.39\\\" cy=\\\"96.83\\\" rx=\\\"22.93\\\" ry=\\\"42.04\\\"></ellipse>\\n </g>\\n </g>\\n</svg>\"},\"link\":\"https://bundlephobia.com/package/axios-cache-interceptor\"},{\"icon\":{\"svg\":\"<svg xmlns=\\\"http://www.w3.org/2000/svg\\\" width=\\\"108\\\" height=\\\"108\\\">\\n <title>Package Phobia</title>\\n <path xmlns=\\\"http://www.w3.org/2000/svg\\\" stroke=\\\"var(--vp-c-text-2)\\\" style=\\\"scale: 18%;\\\" d=\\\"M21.667 73.809V33.867l28.33-16.188 28.337 16.188V66.13L49.997 82.321 35 73.75V41.604l14.997-8.57L65 41.604v16.788l-15.003 8.571-1.663-.95v-16.67l8.382-4.792-6.719-3.838-8.33 4.763V69.88l8.33 4.762 21.67-12.383V37.737l-21.67-12.379-21.663 12.379v39.88L49.997 90 85 70V30L49.997 10 15 30v40z\\\" transform=\\\"matrix(1.25 0 0 1.25 -8.75 -7.5)\\\"></path>\\n</svg>\"},\"link\":\"https://packagephobia.com/result?p=axios-cache-interceptor\"}],\"nav\":[{\"text\":\"Guide\",\"link\":\"/guide\"},{\"text\":\"Config\",\"link\":\"/config\"},{\"text\":\"Others\",\"link\":\"/others/license\"},{\"text\":\"Latest\",\"items\":[{\"text\":\"v0.x\",\"link\":\"https://axios-cache-interceptor.js.org/v0/\"}]}],\"editLink\":{\"pattern\":\"https://github.com/arthurfiorette/axios-cache-interceptor/edit/main/docs/src/:path\"},\"footer\":{\"message\":\"Made with ❤️\",\"copyright\":\"Copyright (c) 2021-present Arthur Fiorette & Contributors\"},\"algolia\":{\"appId\":\"WPY8IFS0UX\",\"apiKey\":\"8cc9e4ff3f98b5854346224aac791bbf\",\"indexName\":\"axios-cache-interceptor-js\"},\"carbonAds\":{\"code\":\"CEBDT27Y\",\"placement\":\"vuejsorg\"},\"sidebar\":[{\"text\":\"Guide\",\"items\":[{\"text\":\"Introduction\",\"link\":\"/guide\"},{\"text\":\"Getting Started\",\"link\":\"/guide/getting-started\"},{\"text\":\"Debugging\",\"link\":\"/guide/debugging\"},{\"text\":\"Storages\",\"link\":\"/guide/storages\"},{\"text\":\"Request Id\",\"link\":\"/guide/request-id\"},{\"text\":\"Invalidating Cache\",\"link\":\"/guide/invalidating-cache\"},{\"text\":\"Comparison\",\"link\":\"/guide/comparison\"},{\"text\":\"Other Interceptors\",\"link\":\"/guide/interceptors\"}]},{\"text\":\"Config\",\"items\":[{\"text\":\"Global Configuration\",\"link\":\"/config\"},{\"text\":\"Request Specifics\",\"link\":\"/config/request-specifics\"},{\"text\":\"Response Object\",\"link\":\"/config/response-object\"}]},{\"text\":\"Others\",\"items\":[{\"text\":\"MIT License\",\"link\":\"/others/license\"},{\"text\":\"Changelog\",\"link\":\"/others/changelog\"}]}]},\"locales\":{},\"scrollOffset\":90,\"cleanUrls\":true}");</script>
|
||
|
||
</body>
|
||
</html> |