Providing context for the revalidation (stale, reconnect, focus, mutate) #2957
Unanswered
dmeehan1968
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a use case where I want (certain users) to be able to force a server side cache invalidation. Basically I have caching on both the client and server, but in the case of a manual revalidation (calling mutate) I want to be able to add a header to the request to tell the server to invalidate its own cache. Note that the data is common to all users, other than in terms of filtering and is cached appropriately.
The main place this could be injected is in the fetcher. It currently receives the key (which might be an object/array) so then constructs the actual request to the remote resource. At this point a header could be added to indicate that the server side should ignore any cache. If the fetcher were called with an additional argument that indicated the reason for the revalidation (stale/reconnect/focus/mutate) then the fetch could be constructed appropriately. I do appreciate that this could lead people to misuse the fetch and construct queries that pollute the cache, but that is already possible.
I can't find anything in the API that suggests the revalidation cause can be 'pulled' from somewhere else, like the global config. I also appreciate that adding another argument to the fetcher could be a breaking change for some fetcher implementations.
Is there a workaround?
Beta Was this translation helpful? Give feedback.
All reactions