WPO Drupal: Don't kill caches!!!!

The other day I had to investigate how to improve the performance of a Drupal website that is not fast enough and has problems with caches.

This website has several things to improve, but the one I'm complaining about today is a custom module with a code equivalent to:

 * Implements hook_views_pre_render().
function my_module_views_pre_render(ViewExecutable $view) {

For those who don't know, by using the KillSwitch class, we can trigger the deletion of the page cache in certain circumstances. And this class is in the page_cache_kill_switch service, so we can call its trigger() method if what we want is to clear the cache of the current page.

The problem is that in this particular case it was launching this cleaning in the hook_views_pre_render, without any kind of filter. Neither by views name, nor page url or anything else.

So, in summary, there is a custom module that has a code that disables/invalidates/removes the page cache on any page that has one view, and on this site more than 90% of the pages have at least 1 view!

It is almost the same as having deactivated the page_cache module (which was still active).

This reminds me of another case of another client who also had similar problems. In that case there were 3 modules that together gave problems. Basically I had the webform module + the captcha (which invalidates the caches of the pages where there are forms) + the quicklink (preloads the visible urls). The problem was that all the pages were preloading the contact page with its corresponding captcha, which invalidated the cache.

What is really wrong is not to remove the cache, is to remove it from most pages, not realizing the problem that this entails and then complaining that Drupal is slow. And this is noticeable when your website is medium/large and you have thousands of daily visits.

Have Any Project in Mind?

If you want to do something in Drupal maybe you can hire me.

Either for consulting, development or maintenance of Drupal websites.