Bug 244000 - NetworkCache uses URL instead of URI as a part of caching key
Summary: NetworkCache uses URL instead of URI as a part of caching key
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: History (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: cathiechen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-08-16 11:07 PDT by cathiechen
Modified: 2022-08-18 11:31 PDT (History)
7 users (show)

See Also:


Attachments
WIP-patch (2.12 KB, patch)
2022-08-16 11:15 PDT, cathiechen
ews-feeder: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description cathiechen 2022-08-16 11:07:12 PDT
Per [1], the key is composed of, at a minimum, the request method and target URI. But in NetworkCache, Cache::makeCacheKey uses URL instead.

We have a test to reproduce that the cache does not work:
  - Open [2] and click the button to add fragment to the URL, then click the link on the page.
  - Terminate safari and reopen it.
  - Hit back button. The page is downloaded from network instead of disk.

Because the browser is terminated, there is no page cache after reopen. Then it goes to network process to get the data, it checks the NetworkCache first,
but there is no entry found for the key does not match. It stores by "https://perfect-lively-xylophone.glitch.me/", but when retrieve, the key is "https://perfect-lively-xylophone.glitch.me/#somefragment".

Not sure if we could treat this key same as the http cache[1], but "fragment identifiers are reserved for client-side processing".
Looks like the cache should be reused.

[1] https://httpwg.org/specs/rfc9111.html#caching.overview
[2] https://perfect-lively-xylophone.glitch.me/
Comment 1 cathiechen 2022-08-16 11:15:34 PDT
Created attachment 461679 [details]
WIP-patch

Upload a WIP patch which use url().stringWithoutFragmentIdentifier() instead of url() as the key.
Comment 2 Alex Christensen 2022-08-16 14:39:46 PDT
This seems like a reasonable change, but needs a test.
Comment 3 Alex Christensen 2022-08-16 14:55:48 PDT
There may be something in LayoutTests/http/tests/cache that is similar to a test we would want for this.
Comment 4 cathiechen 2022-08-18 10:06:43 PDT
Pull request: https://github.com/WebKit/WebKit/pull/3458
Comment 5 cathiechen 2022-08-18 10:13:02 PDT
(In reply to Alex Christensen from comment #3)
> There may be something in LayoutTests/http/tests/cache that is similar to a
> test we would want for this.

Thanks a lot, Alex!
I added a function to generate fragment in LayoutTests/http/tests/cache/disk-cache/resources/cache-test.js
Please take a look at the pull request:)
Comment 6 EWS 2022-08-18 11:30:14 PDT
Committed 253567@main (d62692ae68ab): <https://commits.webkit.org/253567@main>

Reviewed commits have been landed. Closing PR #3458 and removing active labels.
Comment 7 Radar WebKit Bug Importer 2022-08-18 11:31:18 PDT
<rdar://problem/98841865>