diff options
| author | Sam Light <samlight1994@gmail.com> | 2024-06-16 22:27:57 +0100 | 
|---|---|---|
| committer | Sam Light <samlight1994@gmail.com> | 2024-06-16 22:27:57 +0100 | 
| commit | 72c3ccd3028559f52905fdc99217a38046d9cb71 (patch) | |
| tree | e3a221da9eb3e321285bd5feb0f14909097104f3 /src | |
| parent | f7e33f3456406910cba9c4441083191e8d03122d (diff) | |
Setup caching on the svg route
Diffstat (limited to 'src')
| -rw-r--r-- | src/Http/Controllers/SvgController.php | 9 | 
1 files changed, 9 insertions, 0 deletions
| 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,              ]          );      } | 
