-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass through refresh
property to data provider?
#3617
Comments
The I don't see how react-admin could pass that information to the dataProvider. React-admin can't guess your caching policy. In my opinion, it's your job to write a dataProvider that sends a So I'm closing it as it can be solved in userland (in your |
Hmm… your approach (revalidate after previous non-idempotent requests) only applies to the scenario where something was changed in "this" instance of react-admin. The more general case, where data has been modified through any other means, can't be solved that way. You're totally right that react-admin can't guess caching policies, but when the user explicitly expresses they want to see up-to-date data (by clicking the refresh icon), I think it would make sense to pass this intent to the data provider somehow. I agree that the |
In react-admin, the path between the click on Refresh and the actual queries in the data provider takes many, many steps, and passing parameters through these steps isn't possible. So I suggest you solve this in userland, by implementing your own RefreshButton that stores a boolean in sessionStorage to force refresh, and the dataProvider can read this boolean before making requests. |
Alright – thanks for taking the time to explain! |
Is your feature request related to a problem? Please describe.
When working with API resources in react-admin (e.g. displaying objects in a
List
view), changes made through another client are not visible. Clicking the "refresh" icon in the title bar does not help because of HTTP caching. The only way to see recent changes (beyond waiting for the cached responses to expire) is clearing the browser cache.Describe the solution you'd like
I noticed there is already a
refresh
property in some CRUD actions (e.g.crudGetOne
), so I was wondering if it would make sense to add that to all those actions, and pass it through to the data provider (e.g. inparams
). The provider could then set HTTP headers to bypass the cache (Cache-Control: must-revalidate
, I suppose).Describe alternatives you've considered
Haven't really thought about alternative solutions yet, but totally open to suggestions.
If the above idea sounds reasonable, and would be a suitable first contribution (not touching too many parts of the codebase, etc), I'd be up for working on a PR.
The text was updated successfully, but these errors were encountered: