-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WebDriver BiDi] Fix issue with memory cache in Chrome #49904
Conversation
For images I explicitly removed the cache tests because the spec doesn't guarantee that fetch will be used, if the image is already in the document's cached resources. However for scripts I think the HTML spec guarantees that we should hit fetch for each script tag. Of course it can still then hit the cache and avoid the network layer, but I think we should still see a network event (with fromCache: true) for each tag. At least that's what I understand when reading https://html.spec.whatwg.org/#script-processing-model:fetch-a-classic-script ? |
The in-memory caches are not yet specified in the HTML spec:
I think from the BiDi spec perspective we have to report the actual browser behavior here. Chrome's implementation I believe is here https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/loader/fetch/resource_fetcher.cc;l=1449;drc=f39c57f31413abcb41d3068cfb2c7a1718003cc5 @juliandescottes wdyt about landing this test change with a comment about this issue? |
We already had a similar conversation on #48446 :) (which I guess we can close once this lands) It's not clear to me if the scope of the memory cache will apply to loading classic scripts on top of modules, but it's true that the current behavior is not clearly specified, or rather even if it's specified, browsers don't really follow the spec. From the investigation on https://bugzilla.mozilla.org/show_bug.cgi?id=1922527#c1 it sounds like for classic scripts we should always end up doing a fetch, but maybe that will change once memory cache is actually specified. For now sounds fine to update the tests, with comments pointing to the memory cache open issue.
Thinking more about this, I'm wondering how useful (or easy to understand) it is to NOT have events for resources coming from the memory cache vs the HTTP cache. They are both local caches, so clients might have trouble understanding why some resource loads trigger a network event with fromCache: true and others don't. Should we expose memory cache hits as separate events once this is specified? Also in general tests relying on network features should really try to disable the cache as much as possible, so maybe the inconsistencies between browsers is not a huge problem here. |
I believe we would not have any events for requests served from the memory cache as there will be no request created (so there is nothing to set the bits on). From the user perspective, the request that is served from the memory cache never happens (and not visible in DevTools as well). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the comments to explain the situation with memory caches linking to whatwg/html#6110
webdriver/tests/bidi/network/before_request_sent/before_request_sent_cached.py
Outdated
Show resolved
Hide resolved
webdriver/tests/bidi/network/response_completed/response_completed_cached.py
Outdated
Show resolved
Hide resolved
webdriver/tests/bidi/network/response_started/response_started_cached.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Alex Rudenko <[email protected]>
It seem that Chrome sends only 1 request when the there are multiple scripts with the same URL, this look like optimization on our end.
Tested locally with HTML:
And JS: