protected function PageCache::getCacheId in Drupal 9
Same name and namespace in other branches
- 8 core/modules/page_cache/src/StackMiddleware/PageCache.php \Drupal\page_cache\StackMiddleware\PageCache::getCacheId()
Gets the page cache ID for this request.
Parameters
\Symfony\Component\HttpFoundation\Request $request: A request object.
Return value
string The cache ID for this request.
2 calls to PageCache::getCacheId()
- PageCache::get in core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php - Returns a response object from the page cache.
- PageCache::set in core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php - Stores a response object in the page cache.
File
- core/
modules/ page_cache/ src/ StackMiddleware/ PageCache.php, line 348
Class
- PageCache
- Executes the page caching before the main kernel takes over the request.
Namespace
Drupal\page_cache\StackMiddlewareCode
protected function getCacheId(Request $request) {
// Once a cache ID is determined for the request, reuse it for the duration
// of the request. This ensures that when the cache is written, it is only
// keyed on request data that was available when it was read. For example,
// the request format might be NULL during cache lookup and then set during
// routing, in which case we want to key on NULL during writing, since that
// will be the value during lookups for subsequent requests.
if (!isset($this->cid)) {
$cid_parts = [
$request
->getSchemeAndHttpHost() . $request
->getRequestUri(),
$request
->getRequestFormat(NULL),
];
$this->cid = implode(':', $cid_parts);
}
return $this->cid;
}