Effect CommunityEC
Effect Community2y ago
3 replies
giacomo

Integrating `@effect/rpc` with SvelteKit: Handling Cache Misses Due to Dynamic Trace IDs

Hello, I'm working on integrating @effect/rpc and SvelteKit at https://github.com/giacomoran/sveltekit-effect-rpc

In SSR, SvelteKit tries to share code between the server and the client. It provides a custom
fetch
function which, among other things, caches responses in the page HTML. When this custom
fetch
is invoked on the client, it retrieves responses from the HTML cache.
The cache key is a hash of the request body and headers. Headers can be filtered using filterSerializedResponseHeaders.
The challenge I'm facing is that @effect/rpc adds traceId and spanId to each RPC request in the HTTP request body. These IDs differ between server-side and client-side code, leading to cache misses.

I'm currently out of ideas, do you have any suggestions?
Was this page helpful?