Skip to content

Commit 97581eb

Browse files
committed
remove 'public' from cache-control headers
1 parent 786df06 commit 97581eb

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/web/cache.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,15 @@ impl CachePolicy {
5151
]
5252
}
5353
CachePolicy::ForeverInCdnAndBrowser => {
54-
vec![
55-
CacheDirective::Public,
56-
CacheDirective::MaxAge(STATIC_FILE_CACHE_DURATION as u32),
57-
]
54+
vec![CacheDirective::MaxAge(STATIC_FILE_CACHE_DURATION as u32)]
5855
}
5956
CachePolicy::ForeverInCdn => {
6057
// A missing `max-age` or `s-maxage` in the Cache-Control header will lead to
6158
// CloudFront using the default TTL, while the browser not seeing any caching header.
6259
// This means we can have the CDN caching the documentation while just
6360
// issuing a purge after a build.
6461
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html#ExpirationDownloadDist
65-
vec![CacheDirective::Public]
62+
vec![]
6663
}
6764
CachePolicy::ForeverInCdnAndStaleInBrowser => {
6865
let mut directives = CachePolicy::ForeverInCdn.render(config);
@@ -124,11 +121,11 @@ mod tests {
124121
CachePolicy::NoStoreMustRevalidate,
125122
"no-cache, no-store, must-revalidate, max-age=0"
126123
)]
127-
#[test_case(CachePolicy::ForeverInCdnAndBrowser, "public, max-age=31104000")]
128-
#[test_case(CachePolicy::ForeverInCdn, "public")]
124+
#[test_case(CachePolicy::ForeverInCdnAndBrowser, "max-age=31104000")]
125+
#[test_case(CachePolicy::ForeverInCdn, "")]
129126
#[test_case(
130127
CachePolicy::ForeverInCdnAndStaleInBrowser,
131-
"public, stale-while-revalidate=86400"
128+
"stale-while-revalidate=86400"
132129
)]
133130
fn render(cache: CachePolicy, expected: &str) {
134131
wrapper(|env| {
@@ -148,7 +145,7 @@ mod tests {
148145
assert_eq!(
149146
CacheControl(CachePolicy::ForeverInCdnAndStaleInBrowser.render(&env.config()))
150147
.to_string(),
151-
"public"
148+
""
152149
);
153150
Ok(())
154151
});
@@ -163,7 +160,7 @@ mod tests {
163160
assert_eq!(
164161
CacheControl(CachePolicy::ForeverInCdnAndStaleInBrowser.render(&env.config()))
165162
.to_string(),
166-
"public, stale-while-revalidate=666"
163+
"stale-while-revalidate=666"
167164
);
168165
Ok(())
169166
});

src/web/rustdoc.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1778,10 +1778,7 @@ mod test {
17781778
let url = format!("http://{}/dummy", web.server_addr());
17791779
let resp = client.get(url).send()?;
17801780
assert_eq!(resp.status(), StatusCode::FOUND);
1781-
assert_eq!(
1782-
resp.headers().get("Cache-Control").unwrap(),
1783-
reqwest::header::HeaderValue::from_str("public").unwrap()
1784-
);
1781+
assert!(resp.headers().get("Cache-Control").unwrap().is_empty());
17851782
assert!(resp
17861783
.headers()
17871784
.get("Location")

0 commit comments

Comments
 (0)