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!
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!
