Skip to content

Commit 9feb9c6

Browse files
sokraalexkirsz
andauthored
dev-server content might change any time, we can't cache them (vercel/turborepo#4670)
### Description Browser cache might lead to inconsistent state --------- Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
1 parent 5a6d859 commit 9feb9c6

File tree

1 file changed

+8
-0
lines changed
  • crates/turbopack-dev-server/src

1 file changed

+8
-0
lines changed

crates/turbopack-dev-server/src/http.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ pub async fn process_request_with_content_source(
144144
)?);
145145
}
146146

147+
if !header_map.contains_key("cache-control") {
148+
// The dev server contents might change at any time, we can't cache them.
149+
header_map.append(
150+
"cache-control",
151+
hyper::header::HeaderValue::try_from("must-revalidate")?,
152+
);
153+
}
154+
147155
let content = file.content();
148156
let response = if should_compress {
149157
header_map.insert(CONTENT_ENCODING, HeaderValue::from_static("gzip"));

0 commit comments

Comments
 (0)