@@ -50,15 +50,13 @@ public function __construct(Cacher $cacher, Session $nocache)
5050 public function handle ($ request , Closure $ next )
5151 {
5252 if ($ response = $ this ->attemptToServeCachedResponse ($ request )) {
53- return $ this -> addEtagToResponse ( $ request , $ response) ;
53+ return $ response ;
5454 }
5555
5656 $ lock = $ this ->createLock ($ request );
5757
5858 try {
59- return $ lock ->block ($ this ->lockFor ,
60- fn () => $ this ->addEtagToResponse ($ request , $ this ->handleRequest ($ request , $ next ))
61- );
59+ return $ lock ->block ($ this ->lockFor , fn () => $ this ->handleRequest ($ request , $ next ));
6260 } catch (LockTimeoutException $ e ) {
6361 return $ this ->outputRefreshResponse ($ request );
6462 }
@@ -231,24 +229,4 @@ private function outputRefreshResponse($request)
231229
232230 return response ($ html , 503 , ['Retry-After ' => 1 ]);
233231 }
234-
235- private function addEtagToResponse ($ request , $ response )
236- {
237- if (! $ response ->isRedirect () && $ content = $ response ->getContent ()) {
238- // Clear any potentially stale cache-related headers that might interfere
239- $ response ->headers ->remove ('ETag ' );
240- $ response ->headers ->remove ('Last-Modified ' );
241-
242- // Set fresh ETag based on current content
243- $ response ->setEtag (md5 ($ content ));
244-
245- // Only call isNotModified() if request has cache validation headers
246- // This prevents 304 responses to clients that haven't sent If-None-Match or If-Modified-Since
247- if ($ request ->headers ->has ('If-None-Match ' ) || $ request ->headers ->has ('If-Modified-Since ' )) {
248- $ response ->isNotModified ($ request );
249- }
250- }
251-
252- return $ response ;
253- }
254232}
0 commit comments