Bug 255924
Summary: | URI Fragments Cached After 301 Redirect | ||
---|---|---|---|
Product: | WebKit | Reporter: | zachshaw1 |
Component: | Page Loading | Assignee: | 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
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
simon
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
<rdar://problem/108535944>
Brandon
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
*** Bug 257327 has been marked as a duplicate of this bug. ***
Chris Dumez
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
(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
Pull request: https://github.com/WebKit/WebKit/pull/14514
EWS
Committed 265906@main (205444531ae8): <https://commits.webkit.org/265906@main>
Reviewed commits have been landed. Closing PR #14514 and removing active labels.