Fluent with Cacheinclude - translations are not caching only primary

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

I am trying to setup a site with heyday/silverstripe-cacheinclude and tractorcow/silverstripe-fluent.

If have my config for cacheinclude to include the full context of the url and set it to run after the fluent routing but only one translation gets cached. I thought heyday looks at the full request url but it doesn’t seem to be.

Example confing -

SilverStripe\Core\Injector\Injector:
CacheIncludeConfig:
class: Heyday\CacheInclude\Configs\ArrayConfig
properties:
Config:
FullPage:
context: full
expires: ‘+12 hours’
contains:
- Page

I have en_US as primary local and then en_GB as secondary. If I hit the site en_US is cached. If I then go to domain.com/en_GB it should show the translation but it is not working.

Any ideas on how to get these two to work. Tagging @TractorCow if he has any ideas.

Thanks all.

So after some debugging of heyday/silverstripe-cacheinclude - it appears that it is not actually using the full URL for caching but is using the URL segment. If you have two translations with the same URL segment such as the home page being just ‘home’ by SS default, it will always only cache whichever is hit first.

To solve this I created a new key provider like the following -

namespace App\KeyCreators;

use Heyday\CacheInclude\KeyCreators\ControllerBased;
use TractorCow\Fluent\State\FluentState;

class FluentControllerBased extends ControllerBased{
    public function getKey($name, $config){
        $keyParts = parent::getKey($name, $config);
        $state = FluentState::singleton();
        $keyParts[] = md5($state->getDomain());
        $keyParts[] = md5($state->getLocale());
        return $keyParts;
    }
}

I then updated my YML config to use this new class instead -

SilverStripe\Core\Injector\Injector:
  CacheIncludeKeyCreator:
	class: 'App\KeyCreators\FluentControllerBased'

All is working as you would expect it to now.