diff --git a/src/Middleware/StatusCodesCacheMiddleware.php b/src/Middleware/StatusCodesCacheMiddleware.php index 5a6d545..29b3c6f 100644 --- a/src/Middleware/StatusCodesCacheMiddleware.php +++ b/src/Middleware/StatusCodesCacheMiddleware.php @@ -5,8 +5,7 @@ use ACPL\FlarumLSCache\LSCacheHeader; use Flarum\Http\RequestUtil; use Flarum\Settings\SettingsRepositoryInterface; -use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Message\{ResponseInterface, ServerRequestInterface}; use Psr\Http\Server\{MiddlewareInterface, RequestHandlerInterface}; class StatusCodesCacheMiddleware implements MiddlewareInterface @@ -18,7 +17,8 @@ public function __construct(protected SettingsRepositoryInterface $settings) public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $response = $handler->handle($request); - if ($response->hasHeader(LSCacheHeader::CACHE_CONTROL)) { + + if (! in_array($request->getMethod(), ['GET', 'HEAD']) || $response->hasHeader(LSCacheHeader::CACHE_CONTROL)) { return $response; }