Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

ProtocolVersionCacheContext.php

Namespace

Drupal\Core\Cache\Context

File

core/lib/Drupal/Core/Cache/Context/ProtocolVersionCacheContext.php

View source
<?php

namespace Drupal\Core\Cache\Context;

use Drupal\Core\Cache\CacheableMetadata;

/**
 * Defines the ProtocolVersionCacheContext service, for "per protocol" caching.
 *
 * Useful to differentiate between HTTP/1.1 and HTTP/2.0 responses for example,
 * to allow responses to be optimized for protocol-specific characteristics.
 *
 * Cache context ID: 'protocol_version'.
 */
class ProtocolVersionCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getLabel() {
        return t('Protocol version');
    }
    
    /**
     * {@inheritdoc}
     */
    public function getContext() {
        return $this->requestStack
            ->getCurrentRequest()
            ->getProtocolVersion();
    }
    
    /**
     * {@inheritdoc}
     */
    public function getCacheableMetadata() {
        return new CacheableMetadata();
    }

}

Classes

Title Deprecated Summary
ProtocolVersionCacheContext Defines the ProtocolVersionCacheContext service, for "per protocol" caching.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal