Watagori
CDCloudflare Developers
•Created by Watagori on 4/20/2024 in #general-help
Handling Stale Data with Cloudflare KV API After Updating Like Count in a Next.js Application
I'm currently working on a Next.js application where user 'likes' are handled through Cloudflare KV API. To enhance security, these updates are routed through Next.js API routes before directly updating the KV store. Although the updates are reflected correctly in the Cloudflare dashboard, fetching like counts immediately after an update seems to return outdated information. This leads to a less responsive user experience, as the UI doesn't show the updated like counts immediately.
Has anyone experienced similar issues with Cloudflare KV's cache consistency? What strategies did you employ to ensure that your users see the most recent data after an update? Any insights or suggestions on how to handle this stale data problem would be greatly appreciated.
Saving is done with this code.
Acquisition is done with this code
4 replies