Replies: 2 comments 1 reply
-
Hi, I think the HTTP Cache-control mechanism works in the browser itself, not inside the fetcher, when you send http request in your fetcher, if the server responded with a 304 code, the browser will take care of it and in the fetcher, you will already see the response with 200 and cached data from browser. swr will then deep compare the returned data conditionally trigger re-render. |
Beta Was this translation helpful? Give feedback.
1 reply
-
@damischa1 Did you find a good solution for this, I feel like my problem is nearly exactly the same as yours. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am working on shopping cart. The shopping cart is stored in database and possibly shared with multiple users or browser windows.
I would like to implement polling database (using refreshInterval). There is a timestamp in database for the last modification time of the shopping cart. For optimization on the server side we could check if the cart was modified since client browser has last requested it (using if-modified-since -header) and possibly responding HTTP 304 (Not modified).
But how can I signal from the fetcher function that the data on the server was not modified and the client should keep the old version of the cart?
I was thinking of returning previous version of the cart from the SWR cache, but how can I get reference for it in my fetcher?
Beta Was this translation helpful? Give feedback.
All reactions