Bug 255924

Summary: URI Fragments Cached After 301 Redirect
Product: WebKit Reporter: zachshaw1
Component: Page LoadingAssignee: Brandon <brandonstewart>
Status: RESOLVED FIXED    
Severity: Major CC: achristensen, beidson, brandonstewart, bugs-noreply, cdumez, koivisto, mcatanzaro, saralkaushik, simon.khalil, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: All   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=257327

zachshaw1
Reported 2023-04-25 08:12:04 PDT
Version: Safari 16.4 (macOS & iOS) When Safari is redirected by a 301 with URI fragments, for example site.com/page#key=123 -> www.site.com/page#key=123, any subsequent page hits after the 301, Safari will use the initial cached URI fragments. This isn'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 & private browsing both work fine as well.
Attachments
simon
Comment 1 2023-04-25 08:18:39 PDT
I'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
Radar WebKit Bug Importer
Comment 2 2023-04-25 18:38:40 PDT
Brandon
Comment 3 2023-05-25 11:48:29 PDT
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("hello") self.send_response(301) self.send_header('Location', 'http://localhost:8000') self.send_header('Referrer-Policy', 'same-origin') self.end_headers() HTTPServer(('', 10000), Redirect).serve_forever() ################## Server to redirect to python3 -m http.server --bind 127.0.0.1 --directory . 8000 index.html <!DOCTYPE html> <html> <p>Hello World</p> </html> 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 -> URL Result localhost:10000/#key=foo -> localhost:8000/#key=foo localhost:10000/#key=bar -> localhost:8000/#key=foo localhost:10000/#key=bar -> localhost:8000/#key=bar
Chris Dumez
Comment 4 2023-05-30 13:49:05 PDT
*** Bug 257327 has been marked as a duplicate of this bug. ***
Chris Dumez
Comment 5 2023-05-30 13:50:26 PDT
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.
Chris Dumez
Comment 6 2023-05-30 13:53:15 PDT
(In reply to Chris Dumez from comment #5) > 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. 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) -> 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.
Brandon
Comment 7 2023-05-30 16:26:28 PDT
EWS
Comment 8 2023-07-10 10:04:26 PDT
Committed 265906@main (205444531ae8): <https://commits.webkit.org/265906@main> Reviewed commits have been landed. Closing PR #14514 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.