cloudflare / cloudflare-docs

Cloudflare’s documentation
https://developers.cloudflare.com
Creative Commons Attribution 4.0 International
2.92k stars 3.32k forks source link

Add documentation about caching options #14231

Open onepixelsolid opened 4 months ago

onepixelsolid commented 4 months ago

Existing documentation URL(s)

What changes are you suggesting?

It's currently not clear what options you have for Nextjs caching with Cloudflare. Specifically how you can hook up a reliable distributed cache setup by adding Workers KV as your cache binding. This to me is critical coming from Vercel where caching performs as well as Workers KV out-of-the-box.

The suggestion is to add a clear section on this page outlining the standard cache and the Workers KV cache. Much like the information on this page. Or at a minimum, having a section called "Caching" on the page with a link to that caching doc.

Until finding this documentation, I'd spent a week debugging why my Nextjs app (using SSR / app router) was showing old data on browsers in various locations. This was happening via initial load, page refresh and the router cache. It was very unstable. Once we added Workers KV as the cache store it solved all these issues 💥

Additional information

No response

dario-piotrowicz commented 3 months ago

Thanks a bunch for the issue @scottmackenzzz :pray:

I'm sorry you had a hard time with the Next.js caching due to the difficult to find/unclear documentation on our side :sweat:

Hopefully https://github.com/cloudflare/next-on-pages/pull/796 and https://github.com/cloudflare/cloudflare-docs/pull/14859 should improve the situation :slightly_smiling_face:

Please let me know what you think :pray: