Two parallel network requests to the same URL

64 views
Skip to first unread message

Christian Biesinger

unread,
Jul 13, 2022, 1:20:32 PM7/13/22
to net-dev, Yi Gu
Hello net-dev!

With FedCM, we may end up in a place where there's two requests to the
same URL at the same time (basically if JS calls the API from multiple
frames at ~the same time)

These would be with an opaque NIK. I was wondering how the networking
stack handles this. Will it make two requests to the server or somehow
coalesce them?

Thanks!
Christian

Maksim Orlovich

unread,
Jul 13, 2022, 1:31:44 PM7/13/22
to Christian Biesinger, net-dev, Yi Gu
In the normal (I think) case, when cache partitioning is on, these
will be two requests, as coalescing is done by cache layer and it
can't cache with an opaque NIK as part of the key.

Matt Menke

unread,
Jul 13, 2022, 1:35:57 PM7/13/22
to Christian Biesinger, net-dev, Yi Gu
The cache layer will serialize requests whose responses may potentially be used for each other, at least until the first request gets headers (Then the cache layer will merge the requests, if it can, depending on caching response headers).

If NIKs are enabled at the cache layer, requests with transient NIKs bypass the cache (even if the NIKs are the same), so there's no problem.

If NIKs are disabled at the cache layer (As is the case in AndroidWebView and cast, and may be the case if we're running eperiments that disable cache partitioning, or for 3P embedders), then the responses to the requests can potentially be used to service each other, so there will be blocking.

If this is a problem, I suggest just using the LOAD_BYPASS_CACHE load flag, which will always bypass the cache, and make the issue moot.

On Wed, Jul 13, 2022 at 1:20 PM Christian Biesinger <cbies...@chromium.org> wrote:
--
You received this message because you are subscribed to the Google Groups "net-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to net-dev+u...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/net-dev/CAPTJ0XFYdExtvM7f9Kt-Brciou8nUnSrX7VP7MsjDm42GUVbmQ%40mail.gmail.com.

Christian Biesinger

unread,
Jul 13, 2022, 1:43:59 PM7/13/22
to Matt Menke, net-dev, Yi Gu
Thanks. I think I would have preferred blocking + using cached but
thanks for the information!

So on regular android + Desktop NIKs are enabled and therefore these
requests never get cached? That is unfortunate :( is there a way
around that (of course still respecting cache-control etc)?

Thanks,
Christian

Matt Menke

unread,
Jul 13, 2022, 2:04:02 PM7/13/22
to Christian Biesinger, net-dev, Yi Gu
Currently, there's no way to use the HTTP cache when using a transient NIK.  There was a way, at one point, to create magic transient NIKs that would be persisted to disk, but the consumer that it was added for never used it, so we removed the feature.

Note that if cross-origin pages triggering the fetch can learn of the timing of the request, the results being cached is potentially a cross-origin information leak, though timing attacks.
Reply all
Reply to author
Forward
0 new messages