Skip to content

Commit 94bfff1

Browse files
[11.x] Introduce if_successful directive for conditional caching control (#50903)
* Introduce if_successful directive for conditional caching control * Update SetCacheHeaders.php --------- Co-authored-by: Taylor Otwell <taylor@laravel.com>
1 parent 209800f commit 94bfff1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Illuminate/Http/Middleware/SetCacheHeaders.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ public function handle($request, Closure $next, $options = [])
5050
$options = $this->parseOptions($options);
5151
}
5252

53+
if (! $response->isSuccessful()) {
54+
return $response;
55+
}
56+
5357
if (isset($options['etag']) && $options['etag'] === true) {
5458
$options['etag'] = $response->getEtag() ?? md5($response->getContent());
5559
}

0 commit comments

Comments
 (0)