@@ -47,7 +47,7 @@ class CodeIgniter
4747 /**
4848 * The current version of CodeIgniter Framework
4949 */
50- public const CI_VERSION = '4.2.3 ' ;
50+ public const CI_VERSION = '4.2.4 ' ;
5151
5252 /**
5353 * App startup time.
@@ -489,20 +489,26 @@ protected function handleRequest(?RouteCollectionInterface $routes, Cache $cache
489489 $ this ->response = $ response ;
490490 }
491491
492- // Cache it without the performance metrics replaced
493- // so that we can have live speed updates along the way.
494- // Must be run after filters to preserve the Response headers.
495- if (static ::$ cacheTTL > 0 ) {
496- $ this ->cachePage ($ cacheConfig );
497- }
492+ // Skip unnecessary processing for special Responses.
493+ if (! $ response instanceof DownloadResponse && ! $ response instanceof RedirectResponse) {
494+ // Cache it without the performance metrics replaced
495+ // so that we can have live speed updates along the way.
496+ // Must be run after filters to preserve the Response headers.
497+ if (static ::$ cacheTTL > 0 ) {
498+ $ this ->cachePage ($ cacheConfig );
499+ }
498500
499- // Update the performance metrics
500- $ output = $ this ->displayPerformanceMetrics ($ this ->response ->getBody ());
501- $ this ->response ->setBody ($ output );
501+ // Update the performance metrics
502+ $ body = $ this ->response ->getBody ();
503+ if ($ body !== null ) {
504+ $ output = $ this ->displayPerformanceMetrics ($ body );
505+ $ this ->response ->setBody ($ output );
506+ }
502507
503- // Save our current URI as the previous URI in the session
504- // for safer, more accurate use with `previous_url()` helper function.
505- $ this ->storePreviousURL (current_url (true ));
508+ // Save our current URI as the previous URI in the session
509+ // for safer, more accurate use with `previous_url()` helper function.
510+ $ this ->storePreviousURL (current_url (true ));
511+ }
506512
507513 unset($ uri );
508514
0 commit comments