steps describing actix web example
This commit is contained in:
parent
c95063e074
commit
f00dbe4091
5 changed files with 8 additions and 10 deletions
|
@ -5,7 +5,6 @@ authors = ["realaravinth <realaravinth@batsense.net>"]
|
|||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[workspace]
|
||||
members = [
|
||||
".",
|
||||
|
|
|
@ -9,7 +9,7 @@ width="250px"
|
|||
Cache Buster
|
||||
</h1>
|
||||
<p>
|
||||
<strong>May your cache long live and prosper!</strong>
|
||||
<strong>May your cache live long and prosper!</strong>
|
||||
</p>
|
||||
|
||||
[![Documentation](https://img.shields.io/badge/docs-master-blue)](https://realaravinth.github.io/cache-buster/cache_buster/index.html)
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"map":{"./static/cachable/svg/file-text.svg":"./dist/svg/file-text.CF57DF252051E7E81C240D36AF1DB8A9DDAF282F9A5E8C338408FE88A6545A02.svg","./static/cachable/svg/credit-card.svg":"./dist/svg/credit-card.DF612AFE367A7B31410F2F6CD3C7B515B0F1889C0107EA695D840DFFA492E07D.svg","./static/cachable/svg/github.svg":"./dist/svg/github.FA9EB1C66F548EC2C7598B94BA6A17275E1EA383D42B6C83351A2388C773E621.svg","./static/cachable/svg/user.svg":"./dist/svg/user.B164ECD2C4A09DC5189F1F252487E2AC6A33646BEA67AF9C528CDA61FE5E146F.svg","./static/cachable/svg/toggle-right.svg":"./dist/svg/toggle-right.15BF49887941593CE3FE09FA73E3CAF1F4B1E8ABCB42A23D85B4FCBC24FDF5AA.svg","./static/cachable/svg/toggle-left.svg":"./dist/svg/toggle-left.E421950C5922E84015F0A86F272AE5637A2ED96E267D2C962543F5994E5D1172.svg","./static/cachable/svg/bell.svg":"./dist/svg/bell.9DA292704EE9907EFDB870F4510C97336977CA27FBFAAD83CF46F8E22D3828F7.svg","./static/cachable/svg/file.svg":"./dist/svg/file.F9E376D9F78FFD918D8D592A8B2D97EAAC14E638B5A7AE3C58DDB075375D8E0E.svg","./static/cachable/svg/shield-off.svg":"./dist/svg/shield-off.85394A6AD92D550F8EBA72AAB095E078E7A0E3359DF81174532C8D1AF53B5876.svg","./static/cachable/svg/eye-off.svg":"./dist/svg/eye-off.939360B335D1D35B57C3E2070129D14ABB168E4AC137B5BE4F6F8BD450B712F5.svg","./static/cachable/svg/log-out.svg":"./dist/svg/log-out.92AB4384FD41D9AFE4735C480361BB64789CD767B7DD0FF3C6F56287B3D4498E.svg","./static/cachable/svg/eye.svg":"./dist/svg/eye.9DE4D24D3C9B055D02B94A8AD65E8C0C644852381FDD131A64448B6DA7859167.svg","./static/cachable/svg/globe.svg":"./dist/svg/globe.44C2A069EBD637663E938ECE7B8E4EC2A8BDE049A8A044EC68D9CB69AE8C592E.svg","./static/cachable/svg/filter.svg":"./dist/svg/filter.6D5FBD96BA2E2020663AAC4994A991295917D73F3592C07EE103647B655A2275.svg","./static/cachable/svg/settings.svg":"./dist/svg/settings.910C6241743C9C694141971BE8E1C4016A1A5BF203E4E9D676D4CE93BD518F4C.svg","./static/cachable/svg/tag.svg":"./dist/svg/tag.E0BC111B8E81BBFC62B6A9E7E4AC162B7085A6543D995B7A0030CB7632901BD4.svg","./static/cachable/svg/moon.svg":"./dist/svg/moon.1E151D68949CA3B2DC7DE34BC25B7586E4175AC3BA7F56DDBB34227334EF7155.svg","./static/cachable/svg/menu.svg":"./dist/svg/menu.A2C4DD00686F5D23F78885AC4CE3E075FCA78DFBDEA70407667FBBD9801B7A75.svg","./static/cachable/img/Spock_vulcan-salute.png":"./dist/img/Spock_vulcan-salute.50BD6BD857160173DDF9A35A751F5755A3ED3B471F1628D5CD0542B635C18068.png","./static/cachable/svg/home.svg":"./dist/svg/home.28C26C2D3E4013D24D755A589A80D8DD5C49DA5397032E3F09B76BC3A2C314ED.svg","./static/cachable/svg/help-circle.svg":"./dist/svg/help-circle.BE230ABD2E05EB05EF6C5B7D04D35A3A43637EF1E046DEF3D244425609B99F81.svg","./static/cachable/svg/shield.svg":"./dist/svg/shield.13AFE15DCB4882B4A940CFDC3E2088A733CD4E6F97F25B211D87C7C9D6DBA2B6.svg","./static/cachable/css/main.css":"./dist/css/main.C9D814A73388500CC43B26842F4EE585CD53535A6EC915A3153DC5107C1FA1C1.css"},"base_dir":"./dist"}
|
||||
{"map":{"./static/cachable/svg/moon.svg":"./dist/svg/moon.1E151D68949CA3B2DC7DE34BC25B7586E4175AC3BA7F56DDBB34227334EF7155.svg","./static/cachable/svg/shield.svg":"./dist/svg/shield.13AFE15DCB4882B4A940CFDC3E2088A733CD4E6F97F25B211D87C7C9D6DBA2B6.svg","./static/cachable/svg/filter.svg":"./dist/svg/filter.6D5FBD96BA2E2020663AAC4994A991295917D73F3592C07EE103647B655A2275.svg","./static/cachable/svg/settings.svg":"./dist/svg/settings.910C6241743C9C694141971BE8E1C4016A1A5BF203E4E9D676D4CE93BD518F4C.svg","./static/cachable/svg/menu.svg":"./dist/svg/menu.A2C4DD00686F5D23F78885AC4CE3E075FCA78DFBDEA70407667FBBD9801B7A75.svg","./static/cachable/svg/log-out.svg":"./dist/svg/log-out.92AB4384FD41D9AFE4735C480361BB64789CD767B7DD0FF3C6F56287B3D4498E.svg","./static/cachable/img/Spock_vulcan-salute.png":"./dist/img/Spock_vulcan-salute.50BD6BD857160173DDF9A35A751F5755A3ED3B471F1628D5CD0542B635C18068.png","./static/cachable/svg/bell.svg":"./dist/svg/bell.9DA292704EE9907EFDB870F4510C97336977CA27FBFAAD83CF46F8E22D3828F7.svg","./static/cachable/svg/file-text.svg":"./dist/svg/file-text.CF57DF252051E7E81C240D36AF1DB8A9DDAF282F9A5E8C338408FE88A6545A02.svg","./static/cachable/svg/globe.svg":"./dist/svg/globe.44C2A069EBD637663E938ECE7B8E4EC2A8BDE049A8A044EC68D9CB69AE8C592E.svg","./static/cachable/svg/github.svg":"./dist/svg/github.FA9EB1C66F548EC2C7598B94BA6A17275E1EA383D42B6C83351A2388C773E621.svg","./static/cachable/svg/file.svg":"./dist/svg/file.F9E376D9F78FFD918D8D592A8B2D97EAAC14E638B5A7AE3C58DDB075375D8E0E.svg","./static/cachable/svg/home.svg":"./dist/svg/home.28C26C2D3E4013D24D755A589A80D8DD5C49DA5397032E3F09B76BC3A2C314ED.svg","./static/cachable/svg/toggle-left.svg":"./dist/svg/toggle-left.E421950C5922E84015F0A86F272AE5637A2ED96E267D2C962543F5994E5D1172.svg","./static/cachable/svg/user.svg":"./dist/svg/user.B164ECD2C4A09DC5189F1F252487E2AC6A33646BEA67AF9C528CDA61FE5E146F.svg","./static/cachable/svg/shield-off.svg":"./dist/svg/shield-off.85394A6AD92D550F8EBA72AAB095E078E7A0E3359DF81174532C8D1AF53B5876.svg","./static/cachable/svg/toggle-right.svg":"./dist/svg/toggle-right.15BF49887941593CE3FE09FA73E3CAF1F4B1E8ABCB42A23D85B4FCBC24FDF5AA.svg","./static/cachable/svg/help-circle.svg":"./dist/svg/help-circle.BE230ABD2E05EB05EF6C5B7D04D35A3A43637EF1E046DEF3D244425609B99F81.svg","./static/cachable/css/main.css":"./dist/css/main.C9D814A73388500CC43B26842F4EE585CD53535A6EC915A3153DC5107C1FA1C1.css","./static/cachable/svg/eye-off.svg":"./dist/svg/eye-off.939360B335D1D35B57C3E2070129D14ABB168E4AC137B5BE4F6F8BD450B712F5.svg","./static/cachable/svg/eye.svg":"./dist/svg/eye.9DE4D24D3C9B055D02B94A8AD65E8C0C644852381FDD131A64448B6DA7859167.svg","./static/cachable/svg/credit-card.svg":"./dist/svg/credit-card.DF612AFE367A7B31410F2F6CD3C7B515B0F1889C0107EA695D840DFFA492E07D.svg","./static/cachable/svg/tag.svg":"./dist/svg/tag.E0BC111B8E81BBFC62B6A9E7E4AC162B7085A6543D995B7A0030CB7632901BD4.svg"},"base_dir":"./dist"}
|
|
@ -11,9 +11,12 @@ use rust_embed::RustEmbed;
|
|||
use cache_buster::Files;
|
||||
|
||||
mod index;
|
||||
|
||||
/// 1. Set a riddicolusly high cache age
|
||||
pub const CACHE_AGE: u32 = 60 * 60 * 24 * 365;
|
||||
|
||||
lazy_static! {
|
||||
/// 2. create filemap
|
||||
pub static ref FILES: Files = {
|
||||
let map = include_str!("./cache_buster_data.json");
|
||||
Files::new(&map)
|
||||
|
@ -26,12 +29,6 @@ async fn main() -> std::io::Result<()> {
|
|||
std::env::set_var("RUST_LOG", "info");
|
||||
|
||||
let ip = "localhost:2080";
|
||||
crate::FILES
|
||||
.get_full_path("./static/cachable/img/Spock_vulcan-salute.png")
|
||||
.expect("unable to find Spock Vulcan salute image");
|
||||
crate::FILES
|
||||
.get("./static/cachable/css/main.css")
|
||||
.expect("unable to find CSS");
|
||||
|
||||
pretty_env_logger::init();
|
||||
|
||||
|
@ -48,6 +45,7 @@ async fn main() -> std::io::Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// 3. Embed files. Or not. You can also read files dynamically
|
||||
#[derive(RustEmbed)]
|
||||
#[folder = "dist/"]
|
||||
struct Asset;
|
||||
|
@ -61,6 +59,7 @@ fn handle_assets(path: &str) -> HttpResponse {
|
|||
};
|
||||
|
||||
HttpResponse::Ok()
|
||||
// 3. Set proper cache-control headers with cache age set from step 1
|
||||
.insert_header(header::CacheControl(vec![
|
||||
header::CacheDirective::Public,
|
||||
header::CacheDirective::Extension("immutable".into(), None),
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
Cache Buster
|
||||
</h1>
|
||||
<h2>
|
||||
May your cache long live and prosper!
|
||||
May your cache live long and prosper!
|
||||
</h2>
|
||||
|
||||
<h3>What is cache busting?</h3>
|
||||
|
|
Loading…
Reference in a new issue