Crates.io | rocket_cc_file_server |
lib.rs | rocket_cc_file_server |
version | 0.1.0-beta.1 |
source | src |
created_at | 2022-07-02 17:12:11.446212 |
updated_at | 2022-09-07 12:31:27.862279 |
description | A custom FileServer providing better cache control for the Rocket web framework. |
homepage | |
repository | https://github.com/DerPizzaBoi/rocket_cc_file_server |
max_upload_size | |
id | 617901 |
size | 57,543 |
A custom implementation of the Rocket FileServer, that supports headers for cache control. CCFileServer can be used as a drop in replacement for Rocket's FileServer.
Set your own caching rules, while keeping rockets FileServer Options
It is this easy to use:
#[launch]
fn rocket() -> Rocket<Build> {
let options = CCOptions::builder()
.max_age(Some(300))
.no_cache(Some(()));
rocket::build()
.mount("/assets", CCFileServer::from("www/public/assets"))
.mount("/js", CCFileServer::new("www/public/js", options))
}
Mount the CCFileServer the same way you mount a normal rocket FileServer.
Additionally, you need to provide a CCOptions struct to configure the headers of the CCFileServer. Every field that has Some value will be set as a header.
Right now it is just a prototype. There are still some things to do: