use Cache-Control for posts images

This commit is contained in:
Swrup 2022-04-04 17:33:49 +02:00
parent a6edfce5d8
commit d57c359b1f

View file

@ -304,7 +304,14 @@ let get_post_image ~thumbnail request =
| Ok image_opt -> (
match image_opt with
| None -> Dream.respond ~status:`Not_Found "Image does not exists"
| Some image -> Dream.respond ~headers:[ ("Content-Type", "image") ] image )
| Some image ->
(* posts images do not change so we cache them *)
Dream.respond
~headers:
[ ("Cache-Control", "max-age=3628800, immutable")
; ("Content-Type", "image")
]
image )
let get_avatar_image request =
let nick = Dream.param request "user" in