Skip to content

Commit

Permalink
fix: Also add any token to the meta container cache key for regular…
Browse files Browse the repository at this point in the history
… requests
  • Loading branch information
khalwat committed Aug 14, 2024
1 parent 2353e32 commit cd3751f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/services/MetaContainers.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use yii\base\Exception;
use yii\base\InvalidConfigException;
use yii\caching\TagDependency;
use yii\web\BadRequestHttpException;
use function is_array;
use function is_object;

Expand Down Expand Up @@ -394,8 +395,17 @@ public function loadMetaContainers(?string $uri = '', int $siteId = null, ?Eleme
Seomatic::$previewingMetaContainers = true;
}
}
// Cache requests that have a token associated with them separately
$token = '';
$request = Craft::$app->getRequest();
if (!$request->isConsoleRequest) {
try {
$token = $request->getToken() ?? '';
} catch (BadRequestHttpException $e) {
}
}
// Get our cache key
$cacheKey = $uri . $siteId . $paginationPage . $requestPath . $this->getAllowedUrlParams();
$cacheKey = $uri . $siteId . $paginationPage . $requestPath . $this->getAllowedUrlParams() . $token;
// For requests with a status code of >= 400, use one cache key
if (!$request->isConsoleRequest) {
$response = Craft::$app->getResponse();
Expand Down

0 comments on commit cd3751f

Please sign in to comment.