axios-extensions icon indicating copy to clipboard operation
axios-extensions copied to clipboard

Invalidate cache when PUT/PATCH/DELETE requests are made to same URL

Open adamreisnz opened this issue 5 years ago • 4 comments

Suppose you cache a GET request to /foo/123.

Can the adapter be smart enough to invalidate this cache entry when it detects a PUT/PATCH/DELETE request to the same URL?

A similar feature exists in axios-cache-adapter and would be useful to have so we don't have to write it ourselves outside of the adapter.

adamreisnz avatar Jan 12 '20 05:01 adamreisnz

Totally agree, we write this in to our own logic, but it makes sense that if an update is made it clears the cache entry

Hyperblaster avatar Mar 30 '20 01:03 Hyperblaster

It would be great if this feature will be implemented

v-vovk avatar Jun 17 '21 16:06 v-vovk

Totally agree, we write this in to our own logic, but it makes sense that if an update is made it clears the cache entry

can you share your realization pls?

v-vovk avatar Jun 17 '21 16:06 v-vovk

+1 for this feature. Could be also a configuration of cache adapter to behave like this.

Also, I believe cache of GET to /foo must be invalidated along with cache for /foo/123 in case of PUT/PATCH/DELETE request to /foo/123. In most cases GET /foo returns list of items and if some of such items updated — better to invalidate cache for list also.

kopach avatar Nov 17 '21 13:11 kopach