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
1 changed files with 9 additions and 7 deletions

View File

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