Wrap server in header middleware with a sane CacheControl policy to satisfy lighthouse
This commit is contained in:
parent
71bbd3bfbd
commit
68fca7cbde
1 changed files with 5 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
use actix_cors::Cors;
|
||||
use actix_files::Files;
|
||||
use actix_web::http::header::{CacheControl, CacheDirective};
|
||||
use actix_web::middleware;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{web::scope, App, HttpServer};
|
||||
|
@ -55,6 +56,10 @@ async fn main() -> std::io::Result<()> {
|
|||
.wrap(middleware::Compress::default())
|
||||
.wrap(middleware::Logger::new("%s %r"))
|
||||
.wrap(middleware::NormalizePath::trim())
|
||||
.wrap(
|
||||
middleware::DefaultHeaders::new()
|
||||
.add(CacheControl(vec![CacheDirective::MaxAge(31536000)])),
|
||||
)
|
||||
.service(
|
||||
scope("/api")
|
||||
.service(get_posts)
|
||||
|
|
Loading…
Reference in a new issue