Provide Cache-Control Headers
max-age = 1 week for everything stale-while-revalidate = 1 day for everything except raw pastes immutable for raw pastes Most likely fixes #2, unless I forgot something. Suggested-by: Leonora Tindall <ltindall@fastly.com> Signed-off-by: Gunwant Jain <mail@wantguns.dev>
This commit is contained in:
parent
884be16dc4
commit
08ec2cbecb
4 changed files with 34 additions and 9 deletions
|
|
@ -2,9 +2,11 @@ use rocket_dyn_templates::Template;
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::models::response_wrapper::ResponseWrapper;
|
||||
|
||||
#[get("/")]
|
||||
pub async fn index() -> Option<Template> {
|
||||
pub async fn index() -> ResponseWrapper<Template> {
|
||||
let mut map = HashMap::new();
|
||||
map.insert("title", "bin");
|
||||
Some(Template::render("index.html", &map))
|
||||
ResponseWrapper::meta_response(Template::render("index.html", &map))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,9 @@ pub async fn pretter_retrieve_inner(
|
|||
let rendered = Template::render("pretty.html", &map);
|
||||
|
||||
match tree_magic::match_filepath("text/plain", &filepath) {
|
||||
true => ResponseWrapper::paste_response(rendered, modified_date),
|
||||
true => {
|
||||
ResponseWrapper::pretty_paste_response(rendered, modified_date)
|
||||
}
|
||||
false => ResponseWrapper::server_error("media type unacceptable"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,5 +42,5 @@ pub async fn retrieve_inner(id: &str) -> ResponseWrapper<File> {
|
|||
}
|
||||
};
|
||||
|
||||
ResponseWrapper::paste_response(file, modified_date)
|
||||
ResponseWrapper::raw_paste_response(file, modified_date)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue