src/Control/HTTP.php
public static function augmentState(HTTPRequest $request, HTTPResponse $response)
    {
        // Skip if deprecated API is disabled
        $config = Config::forClass(HTTP::class);
        if ($config->get('ignoreDeprecatedCaching')) {
            return;
        }

        $cacheControlMiddleware = HTTPCacheControlMiddleware::singleton();

        // if http caching is disabled by config, disable it - used on dev environments due to frequently changing
        // templates and other data. will be overridden by forced publicCache(true) or privateCache(true) calls
        if ($config->get('disable_http_cache')) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultState/.defaultForcingLevel instead');
            $cacheControlMiddleware->disableCache();
        }

        // if no caching ajax requests, disable ajax if is ajax request
        if (!$config->get('cache_ajax_requests') && Director::is_ajax()) {
            Deprecation::notice(
                '5.0',
                'HTTP.cache_ajax_requests config is deprecated. Use HTTPCacheControlMiddleware::disableCache() instead'
            );
            $cacheControlMiddleware->disableCache();
        }

        // Pass vary to middleware
        $configVary = $config->get('vary');
        if ($configVary) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultVary instead');
            $cacheControlMiddleware->addVary($configVary);
        }

        // Pass cache_control to middleware
        $configCacheControl = $config->get('cache_control');
        if ($configCacheControl) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware API instead');

            $supportedDirectives = ['max-age', 'no-cache', 'no-store', 'must-revalidate'];
            if ($foundUnsupported = array_diff(array_keys($configCacheControl), $supportedDirectives)) {
                throw new \LogicException(
                    'Found unsupported legacy directives in HTTP.cache_control: ' .
                    implode(', ', $foundUnsupported) .
                    '. Please use HTTPCacheControlMiddleware API instead'
                );
            }

            if (isset($configCacheControl['max-age'])) {
                $cacheControlMiddleware->setMaxAge($configCacheControl['max-age']);
            }

            if (isset($configCacheControl['no-cache'])) {
                $cacheControlMiddleware->setNoCache((bool)$configCacheControl['no-cache']);
            }

            if (isset($configCacheControl['no-store'])) {
                $cacheControlMiddleware->setNoStore((bool)$configCacheControl['no-store']);
            }

            if (isset($configCacheControl['must-revalidate'])) {
                $cacheControlMiddleware->setMustRevalidate((bool)$configCacheControl['must-revalidate']);
            }
        }

        // Set modification date
        if (self::$modification_date) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
            $cacheControlMiddleware->registerModificationDate(self::$modification_date);
        }

        // Ensure deprecated $etag property is assigned
        if (self::$etag && !$cacheControlMiddleware->hasDirective('no-store') && !$response->getHeader('ETag')) {
            Deprecation::notice('5.0', 'Etag should not be set explicitly');
            $response->addHeader('ETag', self::$etag);
        }
    }
public static function augmentState(HTTPRequest $request, HTTPResponse $response)
    {
        // Skip if deprecated API is disabled
        $config = Config::forClass(HTTP::class);
        if ($config->get('ignoreDeprecatedCaching')) {
            return;
        }

        $cacheControlMiddleware = HTTPCacheControlMiddleware::singleton();

        // if http caching is disabled by config, disable it - used on dev environments due to frequently changing
        // templates and other data. will be overridden by forced publicCache(true) or privateCache(true) calls
        if ($config->get('disable_http_cache')) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultState/.defaultForcingLevel instead');
            $cacheControlMiddleware->disableCache();
        }

        // if no caching ajax requests, disable ajax if is ajax request
        if (!$config->get('cache_ajax_requests') && Director::is_ajax()) {
            Deprecation::notice(
                '5.0',
                'HTTP.cache_ajax_requests config is deprecated. Use HTTPCacheControlMiddleware::disableCache() instead'
            );
            $cacheControlMiddleware->disableCache();
        }

        // Pass vary to middleware
        $configVary = $config->get('vary');
        if ($configVary) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware.defaultVary instead');
            $cacheControlMiddleware->addVary($configVary);
        }

        // Pass cache_control to middleware
        $configCacheControl = $config->get('cache_control');
        if ($configCacheControl) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware API instead');

            $supportedDirectives = ['max-age', 'no-cache', 'no-store', 'must-revalidate'];
            if ($foundUnsupported = array_diff(array_keys($configCacheControl), $supportedDirectives)) {
                throw new \LogicException(
                    'Found unsupported legacy directives in HTTP.cache_control: ' .
                    implode(', ', $foundUnsupported) .
                    '. Please use HTTPCacheControlMiddleware API instead'
                );
            }

            if (isset($configCacheControl['max-age'])) {
                $cacheControlMiddleware->setMaxAge($configCacheControl['max-age']);
            }

            if (isset($configCacheControl['no-cache'])) {
                $cacheControlMiddleware->setNoCache((bool)$configCacheControl['no-cache']);
            }

            if (isset($configCacheControl['no-store'])) {
                $cacheControlMiddleware->setNoStore((bool)$configCacheControl['no-store']);
            }

            if (isset($configCacheControl['must-revalidate'])) {
                $cacheControlMiddleware->setMustRevalidate((bool)$configCacheControl['must-revalidate']);
            }
        }

        // Set modification date
        if (self::$modification_date) {
            Deprecation::notice('5.0', 'Use HTTPCacheControlMiddleware::registerModificationDate() instead');
            $cacheControlMiddleware->registerModificationDate(self::$modification_date);
        }

        // Ensure deprecated $etag property is assigned
        if (self::$etag && !$cacheControlMiddleware->hasDirective('no-store') && !$response->getHeader('ETag')) {
            Deprecation::notice('5.0', 'Etag should not be set explicitly');
            $response->addHeader('ETag', self::$etag);
        }
    }
public static function augmentState ( HTTPRequest $ request , HTTPResponse $ response ) { // Skip if deprecated API is disabled $ config = Config :: forClass ( HTTP :: class ) ; if ( $ config -> get ( 'ignoreDeprecatedCaching' ) ) { return ; } $ cacheControlMiddleware = HTTPCacheControlMiddleware :: singleton ( ) ; // if http caching is disabled by config, disable it - used on dev environments due to frequently changing // templates and other data. will be overridden by forced publicCache(true) or privateCache(true) calls if ( $ config -> get ( 'disable_http_cache' ) ) { Deprecation :: notice ( '5.0' , 'Use HTTPCacheControlMiddleware.defaultState/.defaultForcingLevel instead' ) ; $ cacheControlMiddleware -> disableCache ( ) ; } // if no caching ajax requests, disable ajax if is ajax request if ( ! $ config -> get ( 'cache_ajax_requests' ) && Director :: is_ajax ( ) ) { Deprecation :: notice ( '5.0' , 'HTTP.cache_ajax_requests config is deprecated. Use HTTPCacheControlMiddleware::disableCache() instead' ) ; $ cacheControlMiddleware -> disableCache ( ) ; } // Pass vary to middleware $ configVary = $ config -> get ( 'vary' ) ; if ( $ configVary ) { Deprecation :: notice ( '5.0' , 'Use HTTPCacheControlMiddleware.defaultVary instead' ) ; $ cacheControlMiddleware -> addVary ( $ configVary ) ; } // Pass cache_control to middleware $ configCacheControl = $ config -> get ( 'cache_control' ) ; if ( $ configCacheControl ) { Deprecation :: notice ( '5.0' , 'Use HTTPCacheControlMiddleware API instead' ) ; $ supportedDirectives = [ 'max-age' , 'no-cache' , 'no-store' , 'must-revalidate' ] ; if ( $ foundUnsupported = array_diff ( array_keys ( $ configCacheControl ) , $ supportedDirectives ) ) { throw new \ LogicException ( 'Found unsupported legacy directives in HTTP.cache_control: ' . implode ( ', ' , $ foundUnsupported ) . '. Please use HTTPCacheControlMiddleware API instead' ) ; } if ( isset ( $ configCacheControl [ 'max-age' ] ) ) { $ cacheControlMiddleware -> setMaxAge ( $ configCacheControl [ 'max-age' ] ) ; } if ( isset ( $ configCacheControl [ 'no-cache' ] ) ) { $ cacheControlMiddleware -> setNoCache ( ( bool ) $ configCacheControl [ 'no-cache' ] ) ; } if ( isset ( $ configCacheControl [ 'no-store' ] ) ) { $ cacheControlMiddleware -> setNoStore ( ( bool ) $ configCacheControl [ 'no-store' ] ) ; } if ( isset ( $ configCacheControl [ 'must-revalidate' ] ) ) { $ cacheControlMiddleware -> setMustRevalidate ( ( bool ) $ configCacheControl [ 'must-revalidate' ] ) ; } } // Set modification date if ( self :: $ modification_date ) { Deprecation :: notice ( '5.0' , 'Use HTTPCacheControlMiddleware::registerModificationDate() instead' ) ; $ cacheControlMiddleware -> registerModificationDate ( self :: $ modification_date ) ; } // Ensure deprecated $etag property is assigned if ( self :: $ etag && ! $ cacheControlMiddleware -> hasDirective ( 'no-store' ) && ! $ response -> getHeader ( 'ETag' ) ) { Deprecation :: notice ( '5.0' , 'Etag should not be set explicitly' ) ; $ response -> addHeader ( 'ETag' , self :: $ etag ) ; } }
Ensure that all deprecated HTTP cache settings are respected

@deprecated 4.2.0:5.0.0 Use HTTPCacheControlMiddleware instead
@throws \LogicException
@param HTTPRequest $request
@param HTTPResponse $response
Ensure that all deprecated HTTP cache settings are respected