<?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>255924</bug_id>
          
          <creation_ts>2023-04-25 08:12:04 -0700</creation_ts>
          <short_desc>URI Fragments Cached After 301 Redirect</short_desc>
          <delta_ts>2023-07-10 10:04:29 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>Safari 16</version>
          <rep_platform>All</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=257327</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>zachshaw1</reporter>
          <assigned_to name="Brandon">brandonstewart</assigned_to>
          <cc>achristensen</cc>
    
    <cc>beidson</cc>
    
    <cc>brandonstewart</cc>
    
    <cc>bugs-noreply</cc>
    
    <cc>cdumez</cc>
    
    <cc>koivisto</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>saralkaushik</cc>
    
    <cc>simon.khalil</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1951052</commentid>
    <comment_count>0</comment_count>
    <who name="">zachshaw1</who>
    <bug_when>2023-04-25 08:12:04 -0700</bug_when>
    <thetext>Version: Safari 16.4 (macOS &amp; iOS)

When Safari is redirected by a 301 with URI fragments, for example site.com/page#key=123 -&gt; www.site.com/page#key=123, any subsequent page hits after the 301, Safari will use the initial cached URI fragments.

This isn&apos;t happening on any other browser, nor is this happening on Safari 16.3 the new URI fragments are correctly picked up.

Disable Caches enabled &amp; private browsing both work fine as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951056</commentid>
    <comment_count>1</comment_count>
    <who name="simon">simon.khalil</who>
    <bug_when>2023-04-25 08:18:39 -0700</bug_when>
    <thetext>I&apos;m having this issue too. 

Strangely after a 301 the URL fragment is picking up cached values instead of the new fragment values. 

Very odd behaviour</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1951229</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2023-04-25 18:38:40 -0700</bug_when>
    <thetext>&lt;rdar://problem/108535944&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1957971</commentid>
    <comment_count>3</comment_count>
    <who name="Brandon">brandonstewart</who>
    <bug_when>2023-05-25 11:48:29 -0700</bug_when>
    <thetext>Was doing some testing and was able to reproduce back on Safari 16.2 and a recent version of Safari.

Testing

Redirect Server

from http.server import HTTPServer, BaseHTTPRequestHandler

class Redirect(BaseHTTPRequestHandler):
   def do_GET(self):
       print(&quot;hello&quot;)
       self.send_response(301)
       self.send_header(&apos;Location&apos;, &apos;http://localhost:8000&apos;)
       self.send_header(&apos;Referrer-Policy&apos;, &apos;same-origin&apos;)
       self.end_headers()

HTTPServer((&apos;&apos;, 10000), Redirect).serve_forever()

##################

Server to redirect to

python3 -m http.server --bind 127.0.0.1 --directory . 8000

index.html
&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;p&gt;Hello World&lt;/p&gt;
&lt;/html&gt;


URL

Go to localhost:10000/#key=foo
Then go to localhost:10000/#key=bar

I noticed it works correctly on the second time you visit the redirect.

URL Enter -&gt; URL Result
localhost:10000/#key=foo -&gt; localhost:8000/#key=foo 
localhost:10000/#key=bar -&gt; localhost:8000/#key=foo
localhost:10000/#key=bar -&gt; localhost:8000/#key=bar</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958874</commentid>
    <comment_count>4</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-05-30 13:49:05 -0700</bug_when>
    <thetext>*** Bug 257327 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958875</commentid>
    <comment_count>5</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-05-30 13:50:26 -0700</bug_when>
    <thetext>Seem information from dupe at https://bugs.webkit.org/show_bug.cgi?id=257327#c2 to help fix this.

Odds are we simply want to stop caching redirects when the request URL contains a fragment.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958876</commentid>
    <comment_count>6</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2023-05-30 13:53:15 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #5)
&gt; Seem information from dupe at
&gt; https://bugs.webkit.org/show_bug.cgi?id=257327#c2 to help fix this.
&gt; 
&gt; Odds are we simply want to stop caching redirects when the request URL
&gt; contains a fragment.

It is not OK to navigate to https://www.monzo.com/#foo=bar, it is not OK to cache en entry like this:
```
https://www.monzo.com (because we drop fragment from cache keys) -&gt; https://monzo.com/#foo=bar
```

Because this cached redirect would get reused for every load of https://www.monzo.com, no matter the fragment identifier.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1958903</commentid>
    <comment_count>7</comment_count>
    <who name="Brandon">brandonstewart</who>
    <bug_when>2023-05-30 16:26:28 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/14514</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1965966</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2023-07-10 10:04:26 -0700</bug_when>
    <thetext>Committed 265906@main (205444531ae8): &lt;https://commits.webkit.org/265906@main&gt;

Reviewed commits have been landed. Closing PR #14514 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>