]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Middleware/PreventResponseCaching.php
Perms: Fixed some issues made when adding transactions
[bookstack] / app / Http / Middleware / PreventResponseCaching.php
index c763b5fc1bbe4e43d61d62217bc2c682ffdce1fb..a40150444b5fb5d2527ff593aa82ccffece1b205 100644 (file)
@@ -7,6 +7,13 @@ use Symfony\Component\HttpFoundation\Response;
 
 class PreventResponseCaching
 {
+    /**
+     * Paths to ignore when preventing response caching.
+     */
+    protected array $ignoredPathPrefixes = [
+        'theme/',
+    ];
+
     /**
      * Handle an incoming request.
      *
@@ -20,6 +27,13 @@ class PreventResponseCaching
         /** @var Response $response */
         $response = $next($request);
 
+        $path = $request->path();
+        foreach ($this->ignoredPathPrefixes as $ignoredPath) {
+            if (str_starts_with($path, $ignoredPath)) {
+                return $response;
+            }
+        }
+
         $response->headers->set('Cache-Control', 'no-cache, no-store, private');
         $response->headers->set('Expires', 'Sun, 12 Jul 2015 19:01:00 GMT');