From 72c3ccd3028559f52905fdc99217a38046d9cb71 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Sun, 16 Jun 2024 22:27:57 +0100 Subject: Setup caching on the svg route --- src/Http/Controllers/SvgController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Http/Controllers/SvgController.php b/src/Http/Controllers/SvgController.php index 9e9c550..a29fce1 100644 --- a/src/Http/Controllers/SvgController.php +++ b/src/Http/Controllers/SvgController.php @@ -18,11 +18,20 @@ class SvgController extends Controller $svgContent = $collection->getSvg(); if ($svgContent === null) abort(404); + $cacheControl = ''; + if ($request->query('v') && ($maxAge = $collection->getMaxAge()) > 0) { + $cacheControl = "max-age={$maxAge}, public"; + } + else { + $cacheControl = 'no-store, private'; + } + return response( $svgContent, 200, [ 'Content-Type' => 'image/svg+xml', + 'Cache-Control' => $cacheControl, ] ); } -- cgit v1.2.3