vitedge icon indicating copy to clipboard operation
vitedge copied to clipboard

Does it support streaming html?

Open ofek-a opened this issue 3 years ago • 3 comments

My use case requires rapid changing content that therefore can't be cached + also fast TTFB.

Is it possible to stream part of the html instead of sending all of it in one chunk, causing long TTFB?

ofek-a avatar Sep 06 '21 12:09 ofek-a

@OfekA Hi there! Streaming is not supported right now. I think even the worker environment is missing certain APIs related to streaming (https://twitter.com/KentonVarda/status/1425139649681444868).

frandiox avatar Sep 09 '21 08:09 frandiox

@frandiox Hi! Thanks for the reply!

I've been digging through the web and found this article - https://jross.me/server-side-rendering-vue-cloudflare-workers/

Do you think this could somehow be supported? I could even try to tinker with it myself if you think it could be merged back.

ofek-a avatar Sep 09 '21 10:09 ofek-a

@OfekA Ah yes, I remember that article. If you have time to test it then sure, I can help with some guidance:

  • The actual rendering happens in vite-ssr repo.
  • We would need to add an option to the plugin for enabling streaming, and then modify entry-server in vite-ssr accordingly.
  • I think the main challenge is making it work in development with renderToNodeStream and then in prod with renderToWebStream + workarounds. It's also possible to rely on Node 16 native ReadableStream for development, although it's not stable yet.

Tell me if that sounds feasible.

frandiox avatar Sep 09 '21 10:09 frandiox