Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/StaticCaching/NoCache/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Session

protected $url;

private $regionCount = 0;

public function __construct($url)
{
$this->url = $url;
Expand Down Expand Up @@ -55,6 +57,13 @@ public function region(string $key): Region
throw new RegionNotFound($key);
}

public function getRegionId(): string
{
$this->regionCount += 1;

return md5($this->url.$this->regionCount);
}

public function pushRegion($contents, $context, $extension): StringRegion
{
$region = new StringRegion($this, trim($contents), $context, $extension);
Expand Down
4 changes: 1 addition & 3 deletions src/StaticCaching/NoCache/StringRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Statamic\StaticCaching\NoCache;

use Statamic\Support\Str;

class StringRegion extends Region
{
protected $content;
Expand All @@ -15,7 +13,7 @@ public function __construct(Session $session, string $content, array $context, s
$this->content = $content;
$this->context = $this->filterContext($context);
$this->extension = $extension;
$this->key = sha1($content.Str::random());
$this->key = sha1($content).$session->getRegionId();
}

public function key(): string
Expand Down
4 changes: 1 addition & 3 deletions src/StaticCaching/NoCache/ViewRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Statamic\StaticCaching\NoCache;

use Statamic\Support\Str;

class ViewRegion extends Region
{
protected $view;
Expand All @@ -13,7 +11,7 @@ public function __construct(Session $session, string $view, array $context)
$this->session = $session;
$this->view = $view;
$this->context = $this->filterContext($context);
$this->key = Str::random(32);
$this->key = sha1($view).$session->getRegionId();
}

public function key(): string
Expand Down