Skip to content
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

allow forcing refresh of cache using x-api-cache-force-fetch #24

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

peteashworth
Copy link

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.

@arthurfranca
Copy link
Owner

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants