Skip to content

Commit

Permalink
Permit CORS preflight caching
Browse files Browse the repository at this point in the history
With this argument, an incrementing query parameter is added to the URL, which prevents a browser from utilising the CORS preflight cache.

The jQuery documentation states:

> If set to false, it will force requested pages not to be cached by the browser. Note: Setting cache to false will only work correctly with HEAD and GET requests. It works by appending "_={timestamp}" to the GET parameters. The parameter is not needed for other types of requests, except in IE8 when a POST is made to a URL that has already been requested by a GET.

The message_bus middleware implementation [sets the correct headers to prevent the browser caching the actual response](https://github.com/discourse/message_bus/blob/master/lib/message_bus/rack/middleware.rb#L115-L118) so it is unnecessary for the JavaScript client to also force a cache miss in a way that doubles request throughput in a use-case which requires CORS.

Fixes #245
  • Loading branch information
benlangfeld authored and SamSaffron committed Apr 27, 2021
1 parent e30ed86 commit 5c01715
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion assets/message-bus.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
"/poll" +
(!longPoll ? "?dlp=t" : ""),
data: data,
cache: false,
async: true,
dataType: dataType,
type: "POST",
Expand Down

0 comments on commit 5c01715

Please sign in to comment.