Skip to content

Commit

Permalink
Only call store when response still is cacheable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-schranz authored Jul 22, 2024
1 parent 7ec0774 commit 389d421
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/SymfonyCache/EventDispatchingHttpCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ protected function store(Request $request, Response $response)
{
$response = $this->dispatch(Events::PRE_STORE, $request, $response);

parent::store($request, $response);
// CustomTtlListener or other Listener or Subscribers might have set a non-cacheable response so we need revalidate this
// So store is only called when cacheable like Symfony core would do: https://github.com/symfony/symfony/blob/v7.1.2/src/Symfony/Component/HttpKernel/HttpCache/HttpCache.php#L409
if ($response->isCacheable()) {
parent::store($request, $response);
}
}

/**
Expand Down

0 comments on commit 389d421

Please sign in to comment.