<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>233559</bug_id>
          
          <creation_ts>2021-11-29 07:48:20 -0800</creation_ts>
          <short_desc>Cache issue with crossorigin, &apos;vary: *&apos; Responses</short_desc>
          <delta_ts>2021-12-06 07:49:20 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Service Workers</component>
          <version>Safari 15</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Lion Ralfs">lion.ralfs+webkitbugzilla</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>koivisto</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1818212</commentid>
    <comment_count>0</comment_count>
    <who name="Lion Ralfs">lion.ralfs+webkitbugzilla</who>
    <bug_when>2021-11-29 07:48:20 -0800</bug_when>
    <thetext>When attempting to add requests to the cache via the CacheStorage API (https://developer.mozilla.org/en-US/docs/Web/API/CacheStorage), 
any request that results in a response with the response header &apos;vary: *&apos; causes the operation to fail with an error:

&quot;TypeError: Response has a &apos;*&apos; Vary header value&quot;

I&apos;m assuming that this is the expected behavior.

However, when adding a _crossorigin_ request with a &apos;vary: *&apos; header, no error is thrown.

Instead, Safari adds the cache entry without replacing previous entries with the same URL. This becomes evident by repeatedly reloading a page that attempts to add a crossorigin, &apos;vary: *&apos; request to the cache.
If one reads the cache after a few page-reloads (via `cache.matchAll` for example), the same response is returned multiple times.

I&apos;ve isolated a test case in this repository: https://github.com/lionralfs/caches-vary-crossorigin-behavior

1. Run `npm install`
2. Run `npm start`
3. Visit localhost:8000 in Safari
4. Reload the page a few times
5. Click the button to read the cache which displays the cache entries
6. Take a look at the index.html for details

To be honest, I&apos;m not entirely sure what the expected behavior is for crossorigin + &apos;vary: *&apos; responses and I&apos;ve file a Chrome bug as well (since they have a similar issue): https://bugs.chromium.org/p/chromium/issues/detail?id=1274098</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1820611</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-12-06 07:49:20 -0800</bug_when>
    <thetext>&lt;rdar://problem/86103155&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>