Skip to content

Buffer streamed responses before edge caching#6

Merged
gavyncaldwell merged 1 commit intomainfrom
fix/buffer-cached-responses
Mar 13, 2026
Merged

Buffer streamed responses before edge caching#6
gavyncaldwell merged 1 commit intomainfrom
fix/buffer-cached-responses

Conversation

@gavyncaldwell
Copy link
Collaborator

Summary

  • Cache API silently rejects responses without Content-Length
  • TanStack Start uses defaultStreamHandler which streams HTML (chunked transfer encoding)
  • cache.put() from Use Cloudflare Cache API for actual edge caching #5 was silently failing on every request
  • Now buffers the full response body via arrayBuffer() before storing in edge cache

Context

Follow-up to #5 — edge caching still wasn't working because streamed responses can't be cached. This is why Turso reads stayed at 25M after the previous fix.

Cache API rejects responses without Content-Length. TanStack Start
streams HTML (chunked transfer), so cache.put() was silently failing.
Now reads the full response body into an ArrayBuffer first.
@gavyncaldwell gavyncaldwell merged commit c4f1979 into main Mar 13, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant