diff --git a/Dockerfile b/Dockerfile index 6c3c8b9..89008dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.1.12RC1-fpm-alpine3.16 +FROM php:8.4.0RC2-zts-alpine3.20 RUN apk add rsync nginx zlib-dev libpng-dev freetype-dev libjpeg-turbo-dev \ && docker-php-ext-configure gd --with-freetype --with-jpeg \ && docker-php-ext-install -j$(nproc) gd \ diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 8140992..48f2492 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -618,6 +618,7 @@ Class SiteController extends Controller { } //无缓存,则实时生成缩略图 + $minCacheImgSize = 2 * 1024; //最小图片尺寸:20Kb if (empty($cachedData)) { $tmpUrl = parse_url($imgUrl); $img_filepath = __DIR__ . '/../../../www' . $tmpUrl['path']; @@ -631,8 +632,10 @@ Class SiteController extends Controller { //返回图片数据 header("Content-Type: image/jpeg"); - header("Cache-Control: max-age={$small_image_client_cache_seconds}"); - header("Etag: " . md5($img_data)); + if (strlen($img_data) >= $minCacheImgSize) { + header("Cache-Control: max-age={$small_image_client_cache_seconds}"); + header("Etag: " . md5($img_data)); + } echo $img_data; exit; } @@ -648,8 +651,10 @@ Class SiteController extends Controller { } header("Content-Type: {$imgType}"); - header("Cache-Control: max-age={$small_image_client_cache_seconds}"); - header("Etag: {$etag}"); + if (strlen($img_data) >= $minCacheImgSize) { + header("Cache-Control: max-age={$small_image_client_cache_seconds}"); + header("Etag: {$etag}"); + } echo $img_data; exit; }