apicache-plus icon indicating copy to clipboard operation
apicache-plus copied to clipboard

allow forcing refresh of cache using `x-api-cache-force-fetch`

Open peteashworth opened this issue 3 years ago • 1 comments

Scenario: cache is set for 24 hours for load purposes but. a user with higher privilege is able to refresh the cached data via the client (data is pulled from external site)

Leveraged the existing x-api-cache-force-fetch vs having it behave the same way as x-apicache-bypass; which just skips over using the cache but doesn't update it for other updates.

peteashworth avatar Apr 08 '21 04:04 peteashworth

The code seems ok but the problem is that regular users will also be able to use x-api-cache-force-fetch. Maybe you could add an isRefreshable option (default false) so that server owner acknowledges the feature.

This could also be achieved with a middleware above the stack which would check the user privileges and whatever param/header sent to signal the cache refresh and then clear the cache record by key with apicache.getKey(...).then(key => apicache.clear(key))

arthurfranca avatar Oct 14 '21 18:10 arthurfranca