From fef3fe1802a27a8b50a6f5e876680109d308686b Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 17 Jul 2024 15:16:34 +0800 Subject: [PATCH] add cache control for small images --- themes/beauty/controller/SiteController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index c1ee8b0..9ab31a5 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -281,8 +281,11 @@ Class SiteController extends Controller { $imgType = preg_replace('/^data:(image\/.+);base64,.+$/i', "$1", $cachedData); $base64_img = preg_replace('/^data:image\/.+;base64,/i', '', $cachedData); + $img_data = base64_decode($base64_img); header("Content-Type: {$imgType}"); - echo base64_decode($base64_img); + header('Cache-Control: max-age=86400'); + header("Etag: " . md5($img_data)); + echo $img_data; exit; }