Caching Headers

Middleware that provides support for cache header configuration.

In fact, the implementation contains three Handler implementations of CachingHeaders, Modified, ETag, and CachingHeaders is a combination of the latter two. Normally, CachingHeaders is used.

Config Cargo.toml

salvo = { version = "*", features = ["caching-headers"] }

Sample Code

use salvo::prelude::*;

async fn hello_world() -> &'static str {
    "Hello World"

async fn main() {

    tracing::info!("Listening on");
    // CachingHeader must be before Compression.
    let router = Router::with_hoop(CachingHeaders::new())