Skip to content

Commit 9c07413

Browse files
committed
feat(html): cache bust static files by adding hashes to file names
Closes rust-lang#1254
1 parent eaa6914 commit 9c07413

File tree

16 files changed

+447
-217
lines changed

16 files changed

+447
-217
lines changed

Cargo.lock

Lines changed: 66 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ chrono = "0.4"
2121
clap = "2.24"
2222
env_logger = "0.7.1"
2323
handlebars = "3.0"
24+
hex = "0.4"
2425
lazy_static = "1.0"
2526
log = "0.4"
2627
memchr = "2.0"
@@ -30,6 +31,7 @@ regex = "1.0.0"
3031
serde = "1.0"
3132
serde_derive = "1.0"
3233
serde_json = "1.0"
34+
sha2 = "0.9"
3335
shlex = "0.1"
3436
tempfile = "3.0"
3537
toml = "0.5.1"

guide/book.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ edition = "2018"
1010
[output.html]
1111
mathjax-support = true
1212
site-url = "/mdBook/"
13+
hash-files = true
1314

1415
[output.html.playground]
1516
editable = true

src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ pub struct HtmlConfig {
528528
/// The mapping from old pages to new pages/URLs to use when generating
529529
/// redirects.
530530
pub redirect: HashMap<String, String>,
531+
/// If this option is turned on, "cache bust" static files by adding
532+
/// hashes to their file names.
533+
pub hash_files: bool,
531534
}
532535

533536
impl Default for HtmlConfig {
@@ -554,6 +557,7 @@ impl Default for HtmlConfig {
554557
cname: None,
555558
livereload_url: None,
556559
redirect: HashMap::new(),
560+
hash_files: false,
557561
}
558562
}
559563
}

0 commit comments

Comments
 (0)