- Issue created by @ayalon
- First commit to issue fork.
On a large drupal installation with toolbar enabled (also the admin toolbar) we had performance issues.
After debugging and profiling for hours, I found out, that this module is one of the reasons for our performance issues.
The toolbar is rendering the performance preview as part of the toolbar. Unfortunately, the module adds the cache-context "url" in the src/ResponsivePreview.php
file:
if (!$this->currentUser->hasPermission('access responsive preview')) {
return $items;
}
$device_definition = $this->entityTypeManager->getDefinition('responsive_preview_device');
$items['responsive_preview']['#cache']['tags'] = Cache::mergeTags(
$device_definition->getListCacheTags(),
['config:node_type_list'],
);
$items['responsive_preview']['#cache']['contexts'] = Cache::mergeContexts(
$items['responsive_preview']['#cache']['contexts'],
['route.is_admin', 'url'],
);
This means, that the full url path is cached with the whole admin toolbar. The admin toolbar is ususally a large render array with many links. If we add the url
as a cache-context, the toolbar has to be re-rendered for every single admin page.
This is very costly and will slow down your server if you have a lot of editors.
I propose to remove the cache tag or change it to url.site
. It will make your system a lot faster.
Find the attached patch:
Active
2.2
Code