Hot answers tagged

5

Instead of \Drupal::service('router.builder')->rebuild() you can invalidate route matches: Cache::invalidateTags(['route_match']); You don't need to rebuild the router table, because the static routes don't change. What you need to clear are route matches, which are calculated on the processed path and then stored for the unprocessed path. And this is ...


1

To sum up the comments: As a general rule, if you render the current user, then always add the correct cache metadata to the render element: public function build() { return [ '#markup' => '<span>Current User ID: ' . \Drupal::currentUser()->id() . '</span>', '#cache' => [ 'contexts' => ['user'], 'tags'...


1

This is caused by symfony. private is added via vendor/symfony/http-foundation/ResponseHeaderBag.php and as far as I understand it's not possible to not have it when system.performance:cache.page.max_age is set to 0: protected function computeCacheControlValue() { // ... if (!isset($this->cacheControl['s-maxage'])) { return $header.', private'; ...


Only top voted, non community-wiki answers of a minimum length are eligible