apicache-plus
apicache-plus copied to clipboard
allow forcing refresh of cache using `x-api-cache-force-fetch`
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.
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))