Is your feature request related to a problem? Please describe.
Yes, static caching doesn't currently work in a subdomain or multidomain context (we use a custom addon to change out various content like contact details, etc).
It would be great if static caching had an option to nest rendered html into subfolders inside /static based on the current domain. This would allow static caching to work for more complex sites using subdomains.
Describe the solution you'd like
I've managed to get this working by making the following minor changes:
In statamic/core/StaticCaching/FileCacher.php:
Add getCacheDomain():
/**
* Get the current domain
*
* @return string
*/
public function getCacheDomain()
{
return preg_split('/http(s)?:\/\//', url())[1];
}
Update getFilePath():
/**
* Get the path to the cached file.
*
* @param $url
* @return string
*/
public function getFilePath($url)
{
$parts = parse_url($url);
$path = sprintf('%s/%s/%s_%s.html',
$this->getCachePath(),
$this->getCacheDomain(),
$parts['path'],
array_get($parts, 'query', '')
);
return Path::makeFull($path);
}
Is your feature request related to a problem? Please describe. Yes, static caching doesn't currently work in a subdomain or multidomain context (we use a custom addon to change out various content like contact details, etc).
It would be great if static caching had an option to nest rendered html into subfolders inside
/static
based on the current domain. This would allow static caching to work for more complex sites using subdomains.Describe the solution you'd like I've managed to get this working by making the following minor changes:
In
statamic/core/StaticCaching/FileCacher.php
:Add
getCacheDomain()
:Update
getFilePath()
:Nginx config would also need a tiny adjustment:
(I'm not sure what the Apache and IIS changes would need to be)