- Issue created by @c-logemann
- First commit to issue fork.
- 🇧🇪Belgium davidiio
Hello,
We need this on our project so I worked on it and just created an issue fork.
I just added a "Use domain" field on configuration form and then use that inBoostCacheFile.php
prepend (or not) the current domain to the uri.We used that on some test site and it works, with or without domain cache files are created when visiting pages.
One inconsistency though is that when purging in admin interface it is purging every files for every domain while for generating files it generates only for current domain. So one improvement would be to harmonize how it is working there, or give possibility to generate or purge by domain or for all at once (but requires boost to know for which domains to generate cache files)
- 🇮🇳India abhishek@kumar
Path Generation:
// In BoostCache.php or similar protected function getCachePath() { $base_path = parent::getCachePath(); if ($this->config->get('multisite_support')) { $base_path = $base_path . '/' . \Drupal::request()->getHost(); } return $base_path; }
Settings Form Addition:
// In BoostSettingsForm.php
$form['multisite'] = [
'#type' => 'details',
'#title' => $this->t('Multisite settings'),
'#open' => FALSE,
];$form['multisite']['enable_domain_paths'] = [ '#type' => 'checkbox', '#title' => $this->t('Enable domain-specific cache paths'), '#default_value' => $config->get('enable_domain_paths'), '#description' => $this->t('When enabled, each domain will get its own cache subdirectory.'), ];
- 🇧🇪Belgium davidiio
Thanks abhishek@kumar,
I have already done similar changes in the issue fork.
I'd like to have maintainers feedback before making a merge request or imprivement. Or maybe I should make it a merge request to get feedback? - Merge request !20Add configuration for wether to split cache files into domain directories → (Open) created by davidiio
- 🇧🇪Belgium davidiio
For consistency I have also edited getCachedFiles() to get only cached files by domain and be more precise in the description of the use_domain configuration field.
Now when using domain:
- Cache files are separated in domain related directories
- Purge and Generation works only on domain you are currently logged in.I have just noticed while writing this, that the purge on boost_cron() method will work only on base domain so I still have to work on this.
- 🇩🇪Germany c-logemann Frankfurt/M, Germany
The solution for domains in cache file path is similar as on old D7 version. In this way multi domain is possible. But when thinking of multisite (which I didn't used since more than a decade) this can be solved with individual base caching paths configured in each multisite database. So I think we don't need extra support for this when setting a custom path ist working well. This needs a separate Issue I think. So let's focus on multi domain in this issue.
- 🇩🇪Germany c-logemann Frankfurt/M, Germany
On the other side a domain based caching path inside is maybe enough for many multisite setups.