Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Commit

Permalink
Caller should be randomized each time
Browse files Browse the repository at this point in the history
  • Loading branch information
benjohnde committed Mar 23, 2021
1 parent feba4d5 commit 649a2ba
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/CloudFrontInvalidations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Aws\CloudFront\CloudFrontClient;
use Kirby\Cms\Page;
use Kirby\Http\Remote;
use Kirby\Toolkit\Collection;
use Kirby\Toolkit\Str;

class CloudFrontInvalidations
{
Expand Down Expand Up @@ -78,14 +78,12 @@ public static function purgeURLs($pagesOrURLs)
]
]);

$caller = $_ENV['HTTP_HOST'];

foreach (array_chunk($pagesOrURLs, static::API_URL_BATCH_SIZE) as $urlBatch) {
$items = array_values($urlBatch);
$invalidation = [
'DistributionId' => $cloudFrontDistributionId,
'InvalidationBatch' => [
'CallerReference' => $caller,
'CallerReference' => Str::random(16),
'Paths' => [
'Items' => $items,
'Quantity' => count($items)
Expand All @@ -95,5 +93,4 @@ public static function purgeURLs($pagesOrURLs)
$cloudFront->createInvalidation($invalidation);
}
}

}

0 comments on commit 649a2ba

Please sign in to comment.