Skip to content

Commit f82d6e3

Browse files
committed
Applied the same cache-control to render-readme binary
1 parent 311cafd commit f82d6e3

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/bin/render-readmes.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use flate2::read::GzDecoder;
2424
use reqwest::{header, Client};
2525
use tar::{self, Archive};
2626

27+
const CACHE_CONTROL_README: &str = "public,max-age=604800";
2728
const DEFAULT_PAGE_SIZE: usize = 25;
2829
const USAGE: &str = "
2930
Usage: render-readmes [options]
@@ -129,6 +130,8 @@ fn main() {
129130
let content_length = readme.len() as u64;
130131
let content = std::io::Cursor::new(readme);
131132
let readme_path = format!("readmes/{0}/{0}-{1}.html", krate_name, version.num);
133+
let mut extra_headers = header::HeaderMap::new();
134+
extra_headers.insert(header::CACHE_CONTROL, CACHE_CONTROL_README.parse().unwrap());
132135
config
133136
.uploader
134137
.upload(
@@ -137,7 +140,7 @@ fn main() {
137140
content,
138141
content_length,
139142
"text/html",
140-
header::HeaderMap::new(),
143+
extra_headers,
141144
)
142145
.unwrap_or_else(|_| {
143146
panic!(

src/uploaders.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use std::sync::Arc;
1414
use crate::middleware::app::RequestApp;
1515
use crate::models::Crate;
1616

17-
pub const CACHE_CONTROL_IMMUTABLE: &str = "public,max-age=31536000,immutable";
18-
pub const CACHE_CONTROL_README: &str = "public,max-age=604800";
17+
const CACHE_CONTROL_IMMUTABLE: &str = "public,max-age=31536000,immutable";
18+
const CACHE_CONTROL_README: &str = "public,max-age=604800";
1919

2020
#[derive(Clone, Debug)]
2121
pub enum Uploader {

0 commit comments

Comments
 (0)