CINXE.COM
Can web requests that sending in background script use the cache that set by web pages? - Development - Mozilla Discourse
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Can web requests that sending in background script use the cache that set by web pages? - Development - Mozilla Discourse</title> <meta name="description" content="Lets say a web page loaded an image that includes a response header Cache-Control: public, max-age=3600, the image is cached. Then, an add-on (Manifest V3) send a fetch request to the same image in background script. Ca&hellip;"> <meta name="generator" content="Discourse 3.5.0.beta1-dev - https://github.com/discourse/discourse version 2e10fe98a3cb93823b7a2e851c7e12e435434fdd"> <link rel="icon" type="image/png" href="https://us1.discourse-cdn.com/flex001/uploads/mozilla/optimized/3X/6/2/628bcc92bd07c233554241d98da4a5d315ca1234_2_32x32.png"> <link rel="apple-touch-icon" type="image/png" href="https://us1.discourse-cdn.com/flex001/uploads/mozilla/optimized/3X/1/8/180ccfafb4284e125acb62e88c091db07e8a77bb_2_180x180.png"> <meta name="theme-color" media="all" content="#ffffff"> <meta name="color-scheme" content="light"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> <link rel="canonical" href="https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848" /> <link rel="search" type="application/opensearchdescription+xml" href="https://discourse.mozilla.org/opensearch.xml" title="Mozilla Discourse Search"> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/color_definitions_moz-a_6_16_c44324c60f5c4ff92e2067174baa971cfdcfb6ac.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" class="light-scheme"/> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/desktop_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="desktop" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/chat_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="chat" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/checklist_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="checklist" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-adplugin_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-adplugin" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-akismet_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-akismet" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-cakeday_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-cakeday" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-details_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-details" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-lazy-videos_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-lazy-videos" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-local-dates_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-local-dates" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-narrative-bot_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-narrative-bot" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-policy_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-policy" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-presence_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-presence" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-solved_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-solved" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-templates_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-templates" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-topic-voting_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-topic-voting" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/footnote_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="footnote" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/hosted-site_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="hosted-site" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/poll_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="poll" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/spoiler-alert_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="spoiler-alert" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/chat_desktop_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="chat_desktop" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/discourse-topic-voting_desktop_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="discourse-topic-voting_desktop" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/poll_desktop_e0c8127888abaf20fde890f2325052139e839276.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="poll_desktop" /> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/desktop_theme_23_60ae28061b6075c06e55596c64a6d21696002662.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="23" data-theme-name="discotoc"/> <link href="https://sea1.discourse-cdn.com/flex001/stylesheets/desktop_theme_16_851029298ec9c6ad1ae062a8035dca97bf2555a6.css?__ws=discourse.mozilla.org" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="16" data-theme-name="default"/> <link rel="alternate nofollow" type="application/rss+xml" title="RSS feed of 'Can web requests that sending in background script use the cache that set by web pages?'" href="https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848.rss" /> <meta property="og:site_name" content="Mozilla Discourse" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:image" content="https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/1/8/180ccfafb4284e125acb62e88c091db07e8a77bb.png" /> <meta property="og:image" content="https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/1/8/180ccfafb4284e125acb62e88c091db07e8a77bb.png" /> <meta property="og:url" content="https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848" /> <meta name="twitter:url" content="https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848" /> <meta property="og:title" content="Can web requests that sending in background script use the cache that set by web pages?" /> <meta name="twitter:title" content="Can web requests that sending in background script use the cache that set by web pages?" /> <meta property="og:description" content="Lets say a web page loaded an image that includes a response header Cache-Control: public, max-age=3600, the image is cached. Then, an add-on (Manifest V3) send a fetch request to the same image in background script. Can this fetch request utilize the cached image?" /> <meta name="twitter:description" content="Lets say a web page loaded an image that includes a response header Cache-Control: public, max-age=3600, the image is cached. Then, an add-on (Manifest V3) send a fetch request to the same image in background script. Can this fetch request utilize the cached image?" /> <meta property="og:article:section" content="Add-ons" /> <meta property="og:article:section:color" content="669933" /> <meta property="og:article:section" content="Development" /> <meta property="og:article:section:color" content="669933" /> <meta name="twitter:label1" value="Reading time" /> <meta name="twitter:data1" value="1 mins 🕑" /> <meta name="twitter:label2" value="Likes" /> <meta name="twitter:data2" value="3 ❤" /> <meta property="article:published_time" content="2024-10-31T08:17:59+00:00" /> <meta property="og:ignore_canonical" content="true" /> <script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"Can web requests that sending in background script use the cache that set by web pages?","mainEntity":{"@type":"Question","name":"Can web requests that sending in background script use the cache that set by web pages?","text":"Lets say a web page loaded an image that includes a response header Cache-Control: public, max-age=3600, the image is cached.\n\nThen, an add-on (Manifest V3) send a fetch request to the same image in background script. Can this fetch request utilize the cached image?","upvoteCount":1,"answerCount":0,"datePublished":"2024-10-31T08:17:59.753Z","author":{"@type":"Person","name":"yuma","url":"https://discourse.mozilla.org/u/yuma"}}}</script> </head> <body class="crawler browser-update"> <header> <a href="/"> Mozilla Discourse </a> </header> <div id="main-outlet" class="wrap" role="main"> <div id="topic-title"> <h1> <a href="/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848">Can web requests that sending in background script use the cache that set by web pages?</a> </h1> <div class="topic-category" itemscope itemtype="http://schema.org/BreadcrumbList"> <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a href="/c/add-ons/development/108" class="badge-wrapper bullet" itemprop="item"> <span class='badge-category-bg' style='background-color: #669933'></span> <span class='badge-category clear-badge'> <span class='category-name' itemprop='name'>Add-ons</span> </span> </a> <meta itemprop="position" content="1" /> </span> <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a href="/c/add-ons/development/108" class="badge-wrapper bullet" itemprop="item"> <span class='badge-category-bg' style='background-color: #669933'></span> <span class='badge-category clear-badge'> <span class='category-name' itemprop='name'>Development</span> </span> </a> <meta itemprop="position" content="2" /> </span> </div> </div> <div itemscope itemtype='http://schema.org/DiscussionForumPosting'> <meta itemprop='headline' content='Can web requests that sending in background script use the cache that set by web pages?'> <link itemprop='url' href='https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848'> <meta itemprop='datePublished' content='2024-10-31T08:17:59Z'> <meta itemprop='articleSection' content='Development'> <meta itemprop='keywords' content=''> <div itemprop='publisher' itemscope itemtype="http://schema.org/Organization"> <meta itemprop='name' content='Mozilla Community'> <div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject"> <meta itemprop='url' content='https://us1.discourse-cdn.com/flex001/uploads/mozilla/original/3X/3/4/34fadda755c282e21640436c4297fb241915d589.png'> </div> </div> <div id='post_1' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://discourse.mozilla.org/u/yuma'><span itemprop='name'>yuma</span></a> (yuma ) </span> <link itemprop="mainEntityOfPage" href="https://discourse.mozilla.org/t/can-web-requests-that-sending-in-background-script-use-the-cache-that-set-by-web-pages/136848"> <span class="crawler-post-infos"> <time datetime='2024-10-31T08:17:59Z' class='post-time'> October 31, 2024, 8:17am </time> <meta itemprop='dateModified' content='2024-10-31T08:36:30Z'> <span itemprop='position'>1</span> </span> </div> <div class='post' itemprop='text'> <p>Lets say a web page loaded an image that includes a response header <code>Cache-Control: public, max-age=3600</code>, the image is cached.</p> <p>Then, an add-on (Manifest V3) send a fetch request to the same image in background script. Can this fetch request utilize the cached image?</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="1" /> <span class='post-likes'>1 Like</span> </div> </div> <div id='post_3' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://discourse.mozilla.org/u/dotproto'><span itemprop='name'>dotproto</span></a> (Simeon Vincent) </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2024-11-07T00:48:11Z' class='post-time'> November 7, 2024, 12:48am </time> <meta itemprop='dateModified' content='2024-11-07T00:48:11Z'> <span itemprop='position'>3</span> </span> </div> <div class='post' itemprop='text'> <p>Nope. Browsers partition storage in order to prevent trackers from identifying users across sites. The top level browsing context’s origin is used as the partition key. In this case the web page’s cache and the extension’s cache would be separated into different partitions based on their origins. See this MDN article on <a href="https://developer.mozilla.org/en-US/docs/Web/Privacy/State_Partitioning">State Partitioning</a> for more info.</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="2" /> <span class='post-likes'>2 Likes</span> </div> </div> </div> </div> <footer class="container wrap"> <nav class='crawler-nav'> <ul> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/' itemprop="url">Home </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/categories' itemprop="url">Categories </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/guidelines' itemprop="url">Guidelines </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://www.mozilla.org/about/legal/terms/mozilla/' itemprop="url">Terms of Service </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://www.mozilla.org/privacy/websites/' itemprop="url">Privacy Policy </a> </span> </li> </ul> </nav> <p class='powered-by-link'>Powered by <a href="https://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled</p> </footer> <div class="buorg"><div>Unfortunately, <a href="https://www.discourse.org/faq/#browser">your browser is unsupported</a>. Please <a href="https://browsehappy.com">switch to a supported browser</a> to view rich content, log in and reply.</div></div> </body> </html>