Handling POST Requests for Data Retrieval & Caching
Hey everyone,
All API calls in our system use POST, even for retrieving data. Since POST requests don’t get cached at the network level in the browser (unlike GET), this is causing some inefficiencies.
I’m trying to figure out the best way to handle this because:
I don’t want to mutate data evertime component load..
The response is stored in Zustand, but I need a way to avoid unnecessary re-fetching.
Using useEffect for fetching means the POST request will always run on mount, which isn’t ideal .. i can add a check if there's data on zustand store then no need to fetch .. but that is wrong in my case ..
Question:
How do you handle caching for POST requests in such cases? Is there a good workaround,
Would love to hear any best practices or solutions!

5 Replies
yappiest-sapphireOP•8mo ago
this collection i have in postman.. all post is for retrival ..
@TkDodo 🔮 can u kindly guide little bit ..
rival-black•8mo ago
use react-query ?
yappiest-sapphireOP•8mo ago
Yeah, I’m already using React Query. But React Query treats POST requests as mutations (useMutation), which don't have built-in caching like useQuery. My question is—how can I get caching behavior for a POST request, similar to useQuery?
rival-black•8mo ago
But React Query treats POST requests as mutationsit does not react query is a promise based, async state manager you can do whatever you want in your
queryFn as long as you return a promise and you're aware that it can happen a lot (automatic refetches)
if you have an idempotent endpoint that happens to use POST, go for it
graphQL is all post requests and also works fineyappiest-sapphireOP•8mo ago
yeah, got your point! Thanks so much for the clarification! 🙌