dai-shi / react-hooks-fetch

[NOT MAINTAINED] Minimal data fetching library with React Suspense

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

what if two components make requests to the same URL?

NullVoxPopuli opened this issue · comments

like, if I want to use useFetch in a HoC, and that HoC gets used in a few places -- at present, fetch will be invoked once per usage

As you might guess, this hook simply invokes fetch and it doesn't have any caching mechanism by itself. It's up to browser how it's handled. The server may respond with different contents for the same URL (imagine a counter page). Browser could cache the content with proper response headers, but I'm not sure and I didn't experiment on it.

What do you think, and what is your expectation?

I did a bit of experiment in Chrome.

json api

This is JSON API. It seems waiting the first one to finish and then sending the same request.

static file

This is a static file. The second one is finished at the same time and the size is `0 B`.

Closing this one. Feel free to reopen for further discussion.