In my local dev environment drush cr does not rebuild the cache_discovery table. I have to manually truncate it. Is it because expire is set to -1 on all rows? If so, did I mess something up in setting up this site?

I think I could add $settings['cache']['bins']['discovery'] = 'cache.backend.null'; in my local settings file, but then I'd have to truncate it in production when making changes like the one that brought this up. This doesn't seem right.

Maybe I'm just missing a setting somewhere, but drush cr, rebuild.php, and restarting apache all leave cache_discovery exactly as it was.


If you truncate the table cache_discovery and then do a cache-rebuild the table is filled again with data, what would not be, if this was still a cache-clear. In D8 clearing the cache is more like rebuilding the cache, hence the new name. Some tables are still cleared, like the render cache or the twig cache, because these are filled with new data from the result of each request. But the structural data like discovery, router, config and some more are rebuilt, so that the first request after clearing the cache doesn't take too long.

If you set $settings['cache']['bins']['discovery'] = 'cache.backend.null';, then you freeze the table content. It is not touched, even not by a cache rebuild, until you remove this setting.

  • Thanks. So what is the proper way to "re-discover" configuration? For example, adding a form mode to a custom entity. Is truncating the table the only way short of uninstall/reinstall? In this case, the table is not being rebuilt, I took note of the created timestamps and they did not change – Chris Rockwell Jun 2 '17 at 12:43
  • Adding a form mode is discovered by a cache-rebuild. No need to re-install the module. – 4k4 Jun 2 '17 at 13:40
  • Maybe I need to rephrase the question to what would cause a form mode to not be discovered by a cache-rebuild? Every row in cache_discovery has expire set to -1 and doing a cache_rebuild does not update the records. The only way I could get the records to update were to truncate the table and then rebuild the cache. – Chris Rockwell Jun 2 '17 at 14:00
  • On second thought, the original question could just be edited to Why is cache_discovery not rebuilt on cache-rebuild? – Chris Rockwell Jun 2 '17 at 14:03
  • No, expire is not the problem, this is always -1, because a time-based invalidation would make no sense. – 4k4 Jun 2 '17 at 15:06

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.