3 namespace Drupal\Core\Cache\Context;
5 use Drupal\Core\Cache\CacheableMetadata;
8 * Defines the SiteCacheContext service, for "per site" caching.
10 * Cache context ID: 'site'.
12 * A "site" is defined as the combination of URI scheme, domain name, port and
13 * base path. It allows for varying between the *same* site being accessed via
14 * different entry points. (Different sites in a multisite setup have separate
15 * databases.) For example: http://example.com and http://www.example.com.
17 * @see \Symfony\Component\HttpFoundation\Request::getSchemeAndHttpHost()
18 * @see \Symfony\Component\HttpFoundation\Request::getBaseUrl()
20 class SiteCacheContext extends RequestStackCacheContextBase implements CacheContextInterface {
25 public static function getLabel() {
32 public function getContext() {
33 $request = $this->requestStack->getCurrentRequest();
34 return $request->getSchemeAndHttpHost() . $request->getBaseUrl();
40 public function getCacheableMetadata() {
41 return new CacheableMetadata();