Skip to content

Commit

Permalink
Cookies API - added environment to the cache key
Browse files Browse the repository at this point in the history
  • Loading branch information
tg666 committed Oct 4, 2023
1 parent 43589cb commit f44c111
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Api/V1/Controller/CookiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public function getJson(ApiRequest $request, ApiResponse $response): ApiResponse
$requestEntity = $request->getEntity();
assert($requestEntity instanceof CookiesRequestBody);

$etagKey = sprintf('%s/%s/[%s]/json', $projectCode, $requestEntity->locale ?? '_', implode(',', (array) $requestEntity->category));
$etagKey = sprintf(
'%s/%s/%s/[%s]/json',
$projectCode,
$requestEntity->locale ?? '_',
$requestEntity->environment ?? '__default__',
implode(',', (array) $requestEntity->category),
);

if ($this->isNotModified($etagKey, $request)) {
return $response->withStatus(ApiResponse::S304_NOT_MODIFIED);
Expand Down Expand Up @@ -164,7 +170,13 @@ public function getTemplate(ApiRequest $request, ApiResponse $response): ApiResp
$requestEntity = $request->getEntity();
assert($requestEntity instanceof CookiesRequestBody);

$etagKey = sprintf('%s/%s/[%s]/html', $projectCode, $requestEntity->locale ?? '_', implode(',', (array) $requestEntity->category));
$etagKey = sprintf(
'%s/%s/%s/[%s]/html',
$projectCode,
$requestEntity->locale ?? '_',
$requestEntity->environment ?? '__default__',
implode(',', (array) $requestEntity->category),
);

if ($this->isNotModified($etagKey, $request)) {
return $response->withStatus(ApiResponse::S304_NOT_MODIFIED);
Expand Down

0 comments on commit f44c111

Please sign in to comment.