sveltejs / kit

web development, streamlined
https://svelte.dev/docs/kit
MIT License
18.66k stars 1.93k forks source link

Support for Vercel Data Cache. #10845

Open Leftium opened 1 year ago

Leftium commented 1 year ago

Describe the problem

It would be nice if SvelteKit supported Vercel Data Cache.

Data Cache increases web site performance and reduces (external) API usage via fetch(). It is similar to, but different than ISR and Edge Cache (cache control headers).

This feature would probably be specific to the vercel-adapter, but bonus points for making it platform-agnostic.

My specific use case:

Describe the proposed solution

Alternatives considered

Importance

would make my life easier

Additional Information

No response

ww-wolt commented 11 months ago

Is there any workaround available for this? I am programming an events view widget which relies on data of a public google calendar. It would be great to be able to easily cache calls to the Rest API of Google Calender, without having to rely on external caching solutions like Redis.

Leftium commented 11 months ago

Is there any workaround available for this?

I have implemented something using Vercel ISR. The important bits of code are here:

I haven't implemented an interface/API for cache-busting/bypass yet, but you just need to send a header with bypassToken.

If you don't need cache invalidation, you might be able to just use cache control headers

Limitations:

lilnasy commented 6 months ago

Does Vercel document how a framework other than Next.js would implement Data Cache?

mquandalle commented 5 months ago

@Leftium One difference between ISR caching and Vercel data cache is that the later is persisted across deployments which you can't really workaround with your implementation. The only workaround I can think of is to manually use Vercel KV to implement a data cache.