I have a site that is cached for anonymous users. However it seems that something clears caches every now and then (many times daily.) And it is not result of admins activity. I found about it only by chance, when looking at page_cache table, refreshed it after a while and all records were gone. Question: how to start debugging this? What can I do to track what user action or anything causes caches to be cleared? Thank you.
Have you checked whether Cron is configured on your site under Configuration options.
When trying to speed up my site, this article was very useful as Cron will clear cache.
If your cache is cleared on every page, this can be triggered by:
Rebuild the theme registry on every page load
provided by Devel. Try to disable it in Appearance.
Check also your cron tasks.
Since there is no hook on cache clearing (at least not in Drupal 6-7), so debugging this is a bit tricky.
If you really wants to do this (at least not on the Production), enable Devel module, then add:
drupal_flush_all_caches() - not advised).
dd works for Drupal 5-8
To save some space, you can use
debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 3) instead to limit the number of stack frames returned (PHP >= 5.4.0).
This will log all functions/modules which performed clear caching in
To check in real-time once you're using your site, try:
tail -f /tmp/drupal-debug.txt