1

I'm suffering from very long (several second) load times when developing locally with Drupal 8 when developing/debugging twig templates or in general having ALL caching disabled. Rebuilding cache makes my admin pages needlessly require a rebuild for example. When I'm not actually working on them I'd like them to remain cached.

I'd like to be more specific in my cache clearing so that I can clear only the parts I'm actively working on - ex a view or block - instead of constantly invalidating the entire site cache which is rather expensive.

I've found that cache tags may work, but I can't find documentation or the location where I might find a listing of available cache tags or really much else on clearing specific caches. So if tags are effective, where can I find all registered cache tags on my site?

Is there more information I'm missing on how targeted caching is implemented in Drupal 8? Are there alternatives to tags that might work better?

Edit: I should mention my environment, in case there is an alternative solution.

I'm running Drupal using docker, with Nginx/PHP-FPM and MySQL containers , on Docker for Mac which has known issues with file mounts so I'm only mounting my custom modules as volumes into any containers. I profiled the difference between mounting everything and am now spending negligible time doing file operations whereas previously it was very expensive.

Now it appears that my bottleneck is calling the Database many times per pageload, I imagine this is because I'm rebuilding the entire cache meaning I'm adding/removing it from the DB over and over. I may try memcached or redis and see if that helps.

My ideal solution here is to just invalidate portions of the cache I actually want to invalidate instead of the entire thing though. Cached pages are ofc incredibly fast in this environment. My staging environment which is using native Docker does not have the FS issues but still suffers when caches are turned entirely off.

  • You could try using aquia clould, it's free. Local dev is so slow & unproductive. – No Sssweat Aug 30 '16 at 21:19
2

Define all caches disabled, how do you do that?

The recommended approach is to only disable the render cache (as per the example local settings.php), but if you have a complex site and a slow, especially virtualized environmment, that can still take some seconds on every request.

Make sure you don't have xdebug or so constantly enabled. Use PHP7 if possible, that's basically 50% faster. It doesn't make mysql faster obviously, but unless you have very slow/bad queries, that is likely a smaller part of the whole response than you think. And if you have slow queries, then you need to find ways to optimize them, since it will get much morse when you have more parallel page requests.

If you clear cache manually, make sure you use drush cc render and not drush cr unless you actually change something that requires a full cache clear.

Cache tag invalidation doesn't really help that much, you could of course find out the cache tag of your specific block/view and invalidate just that, but there is no drush command for that yet). You could write your own cache backend that extends from the default and allows to ignore cache writes of cache IDs that match a certain pattern. But invalidation will require you to figure out the cache id of the thing, unless you work on the same thing for quite some time, that won't be worth the effort.

For more specific things, you'd need to profile the site to find out what is actually slow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.