Skip to content

Commit c047ede

Browse files
[5.x] Fix static cache file paths for multisite setups
1 parent 7a77568 commit c047ede

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/StaticCaching/Cachers/FileCacher.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ public function cachePage(Request $request, $content)
6767

6868
$content = $this->normalizeContent($content);
6969

70-
$path = $this->getFilePath($url);
70+
$parsed = parse_url($url);
71+
$domain = $parsed['scheme'].'://'.$parsed['host'];
72+
$site = optional(Site::findByUrl($domain))->handle();
73+
$path = $this->getFilePath($url, $site);
7174

7275
if (! $this->writer->write($path, $content, $this->config('lock_hold_length'))) {
7376
return;
@@ -87,8 +90,10 @@ public function preventLoggingRewriteWarning()
8790
public function getCachedPage(Request $request)
8891
{
8992
$url = $this->getUrl($request);
90-
91-
$path = $this->getFilePath($url);
93+
$parsed = parse_url($url);
94+
$domain = $parsed['scheme'].'://'.$parsed['host'];
95+
$site = optional(Site::findByUrl($domain))->handle();
96+
$path = $this->getFilePath($url, $site);
9297

9398
if ($this->logRewriteWarning && ! $this->isLongQueryStringPath($path)) {
9499
Log::debug('Static cache loaded ['.$url.'] If you are seeing this, your server rewrite rules have not been set up correctly.');
@@ -100,8 +105,11 @@ public function getCachedPage(Request $request)
100105
public function hasCachedPage(Request $request)
101106
{
102107
$url = $this->getUrl($request);
108+
$parsed = parse_url($url);
109+
$domain = $parsed['scheme'].'://'.$parsed['host'];
110+
$site = optional(Site::findByUrl($domain))->handle();
103111

104-
return File::exists($this->getFilePath($url));
112+
return File::exists($this->getFilePath($url, $site));
105113
}
106114

107115
/**

0 commit comments

Comments
 (0)