feat: todo's, add image cache control

This commit is contained in:
2026-03-20 21:47:48 +01:00
parent 12388a9908
commit 0dbc9dcbc1
8 changed files with 143 additions and 38 deletions

View File

@@ -11,9 +11,19 @@ pub const MAX_PFP_SIZE: u64 = 8 * 1024 * 1024; // 8 MiB; TODO: might lower, high
/// Default user image to use if users have none
pub const DEFAULT_USER_PFP: &[u8] = include_bytes!("../assets/default-pfp.png");
pub const DEFAULT_USER_PFP_MIME: &str = "image/png; charset=binary";
/// Basically [`USER_CACHES_HEADER`] but much longer for the [`DEFAULT_USER_PFP`]
pub const DEFAULT_USER_PFP_CACHES_HEADER: &str =
crate::utils::web::make_static_cache_header!(Duration::from_hours(2), Duration::from_days(1));
/// TTL for cached user information
/// TTL for cached user information, both in server memory and http's cache-control
pub const USER_CACHES_TTL: Duration = Duration::from_mins(15);
/// TTL for cached user information in CDNs, (stale-while-revalidate), only for non-urgent info
/// (e.g. pfp's)
pub const USER_CDN_CACHES_TTL: Duration = Duration::from_hours(1);
/// Compile-time formatted string for the cache-control header of [`USER_CACHES_TTL`] and
/// [`USER_CDN_CACHES_TTL`]
pub const USER_CACHES_HEADER: &str =
crate::utils::web::make_static_cache_header!(USER_CACHES_TTL, USER_CDN_CACHES_TTL);
/// Paths relative to a user's home to search profile pictures in
pub const USER_PFP_PATHS: &[&str] = &[
@@ -25,3 +35,7 @@ pub const USER_PFP_PATHS: &[&str] = &[
"logo.jpg",
".face",
];
pub mod web_scopes {
pub const IMAGES: &str = "/image";
}