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)

(cherry picked from commit 69fb11f)
  • Loading branch information
nahuel authored and mpetrunic committed Jul 22, 2020
1 parent 04f56fc commit 9ddbfd1
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 @@ -12,7 +12,7 @@ export const plugin: Plugin<Server, IncomingMessage, ServerResponse, SsePluginOp
this.res.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(this.res);
});
};

0 comments on commit 9ddbfd1

Please sign in to comment.