Caching Pages on Sveltekit

Hello!

How can I cache pages on Sveltekit when using Cloudflare pages?

I assumed static pages or pre-rendered pages would automatically be cached but I am consistently seeing Cf-Cache-Status: Dynamic. I have seen some suggestions to create a cache rule that targets load functions by looking for “__data.json” but I was hoping to cache the actual +page.svelte (html) and not the load function.

I’m not currently setting any cookies but is there a way to cache pages on the edge when using cookies?

demo: https://demo.tripcafe.org/
repo: GitHub - hjaber/sveltekit-cf-cache


Thank you for taking a look.

A svelte contributer has solved my question. Cloudflare does not cache HTML pages by default so you must either create a cloudflare page rule or cloudflare cache rule. Cloudflare page rules seem to be more powerful as they cache the load() as well.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.