Override config per role I have implemented a service with the tag config.factory.override. In my class I check if the current user is logged in, and if so I change the system.site.page.front variable to a different page. This kind-of works, but I have a problem with cache. If the first user to visit my site is not logged in that frontpage will be used for everyone, and if a logged in user is first, that version is used for everyone.

This is my current attempt at the getCacheableMetadata: 

/**
 * {@inheritdoc}
 */
public function getCacheableMetadata($name) {
  $metadata = new CacheableMetadata();

  $metadata-&gt;setCacheContexts([$this-&gt;isLoggedIn ? 'user.roles:authenticated' : 'user.roles:anonymous']);

  return $metadata;
}
As @4k4 commented, I don't think that works.

I'd suggest you either use Page Manager/Panels, which allows to create a page with multiple displays and conditions like based on the user role.

Alternatively, you could create your own controller and return the desired page.

I don't know what you want to do exactly, but yet another option would be to keep two separate pages and redirect authenticated users to the different frontpage. That's similar to how drupal.org works, where you can configure whether your front page should be the default or your dashboard as an authenticated user.