blog: use build timestamp as CACHE_VERSION

This commit is contained in:
Peter Cai 2020-04-12 17:14:10 +08:00
parent 311b9a0d26
commit 54ca223ed6
No known key found for this signature in database
GPG key ID: 71F5FB4E4F3FD54F

View file

@ -7,6 +7,7 @@
use crate::store;
use crate::utils::*;
use pulldown_cmark::*;
use rbtag::BuildDateTime;
use serde::{Serialize, Deserialize};
use std::vec::Vec;
@ -115,12 +116,13 @@ impl Post {
}
}
// This should be bumped each time the parsing / compiling
// logic of Markdown changes, and each time the Markdown
// library updates. Updaing this value invalidates all
// existing cache and they will be recompiled when someone
// visits.
const CACHE_VERSION: &'static str = "0017";
lazy_static! {
// Whenever this is changed, all cache will be invalided
// Use build timestamp string
static ref CACHE_VERSION: String = {
format!("{}", BuildTag{}.get_build_timestamp())
};
}
// The prefix path used for caching remote images
pub const IMG_CACHE_PREFIX: &'static str = "/imgcache/";
@ -187,7 +189,7 @@ impl PostContentCache {
Err(_) => return None
};
if cache.version != CACHE_VERSION {
if cache.version != *CACHE_VERSION {
return None;
}