Skip to content

Commit

Permalink
Added "no-transform" to Cache-Control header
Browse files Browse the repository at this point in the history
Some proxies buffers SSE events to compress the stream, delaying the browser event reception. The `no-transform` `Cache-Control` directive forbids this bad behavior. More info at:

facebook/create-react-app#1633
vercel/next.js#9965 (comment)
  • Loading branch information
nahuel authored Jul 22, 2020
1 parent 509106d commit 69fb11f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const plugin: FastifyPluginAsync<SsePluginOptions> =
outputStream.write(serializeSSEEvent({retry: options.retryDelay || 3000}));
this.type("text/event-stream")
.header("Connection", "keep-alive")
.header("Cache-Control", "no-cache");
.header("Cache-Control", "no-cache,no-transform");
toStream(transformAsyncIterable(source)).pipe(outputStream);
});
};

0 comments on commit 69fb11f

Please sign in to comment.