Skip to content

Commit 880ee3f

Browse files
committed
Add extra caching directive to prevent browser from automatically refetching after being idle
1 parent 8eed3ee commit 880ee3f

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

neurow/integration_test/message_brokering_test.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ defmodule Neurow.IntegrationTest.MessageBrokeringTest do
3434

3535
assert_headers(headers, [
3636
{"access-control-allow-origin", "*"},
37-
{"cache-control", "no-cache, no-store"},
37+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
3838
{"connection", "close"},
3939
{"content-type", "text/event-stream"},
4040
{"transfer-encoding", "chunked"}
@@ -91,7 +91,7 @@ defmodule Neurow.IntegrationTest.MessageBrokeringTest do
9191

9292
assert_headers(headers, [
9393
{"access-control-allow-origin", "*"},
94-
{"cache-control", "no-cache, no-store"},
94+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
9595
{"connection", "close"},
9696
{"content-type", "text/event-stream"},
9797
{"transfer-encoding", "chunked"}

neurow/integration_test/message_history_test.exs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ defmodule Neurow.IntegrationTest.MessageHistoryTest do
4646

4747
assert_headers(headers, [
4848
{"access-control-allow-origin", "*"},
49-
{"cache-control", "no-cache, no-store"},
49+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
5050
{"connection", "close"},
5151
{"content-type", "text/event-stream"},
5252
{"transfer-encoding", "chunked"}
@@ -70,9 +70,9 @@ defmodule Neurow.IntegrationTest.MessageHistoryTest do
7070

7171
assert_headers(headers, [
7272
{"access-control-allow-origin", "*"},
73-
{"cache-control", "no-cache, no-store"},
73+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
7474
{"connection", "close"},
75-
{"content-type", "text/event-stream"},
75+
{"content-type", "text/event-stream"}
7676
])
7777

7878
assert_receive %HTTPoison.AsyncChunk{chunk: body}
@@ -112,7 +112,7 @@ defmodule Neurow.IntegrationTest.MessageHistoryTest do
112112

113113
assert_headers(headers, [
114114
{"access-control-allow-origin", "*"},
115-
{"cache-control", "no-cache, no-store"},
115+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
116116
{"connection", "close"},
117117
{"content-type", "text/event-stream"},
118118
{"transfer-encoding", "chunked"}
@@ -139,7 +139,7 @@ defmodule Neurow.IntegrationTest.MessageHistoryTest do
139139

140140
assert_headers(headers, [
141141
{"access-control-allow-origin", "*"},
142-
{"cache-control", "no-cache, no-store"},
142+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
143143
{"connection", "close"},
144144
{"content-type", "text/event-stream"},
145145
{"transfer-encoding", "chunked"}
@@ -171,7 +171,7 @@ defmodule Neurow.IntegrationTest.MessageHistoryTest do
171171

172172
assert_headers(headers, [
173173
{"access-control-allow-origin", "*"},
174-
{"cache-control", "no-cache, no-store"},
174+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
175175
{"connection", "close"},
176176
{"content-type", "text/event-stream"},
177177
{"transfer-encoding", "chunked"}

neurow/integration_test/sse_livecycle_test.exs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ defmodule Neurow.IntegrationTest.SseLifecycleTest do
2626

2727
assert_headers(headers, [
2828
{"access-control-allow-origin", "*"},
29-
{"cache-control", "no-cache, no-store"},
29+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
3030
{"connection", "close"},
3131
{"content-type", "text/event-stream"},
3232
{"transfer-encoding", "chunked"}
@@ -60,7 +60,7 @@ defmodule Neurow.IntegrationTest.SseLifecycleTest do
6060
headers,
6161
[
6262
{"access-control-allow-origin", "*"},
63-
{"cache-control", "no-cache, no-store"},
63+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
6464
{"connection", "close"},
6565
{"content-type", "text/event-stream"},
6666
{"transfer-encoding", "chunked"},
@@ -143,7 +143,7 @@ defmodule Neurow.IntegrationTest.SseLifecycleTest do
143143

144144
assert_headers(headers, [
145145
{"access-control-allow-origin", "*"},
146-
{"cache-control", "no-cache, no-store"},
146+
{"cache-control", "no-cache, no-store, max-age=0, must-revalidate"},
147147
{"connection", "close"},
148148
{"content-type", "text/event-stream"},
149149
{"transfer-encoding", "chunked"}

neurow/lib/neurow/public_api/endpoint.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule Neurow.PublicApi.Endpoint do
4545
conn
4646
|> put_resp_header("content-type", "text/event-stream")
4747
|> put_resp_header("access-control-allow-origin", "*")
48-
|> put_resp_header("cache-control", "no-cache, no-store")
48+
|> put_resp_header("cache-control", "no-cache, no-store, max-age=0, must-revalidate")
4949
|> put_resp_header("connection", "close")
5050
|> put_resp_header("x-sse-timeout", to_string(timeout_ms))
5151
|> put_resp_header("x-sse-keepalive", to_string(keep_alive_ms))

0 commit comments

Comments
 (0)