3

My cache_page table fills up immensely. I see that the expiry field has values = -1. I assume that means it never expires. Which could be why the table fills up so much.

I wrote a hack to get around this, but would really like to know why this is happening so I can fix the root cause instead of adding a hack?

8
  • Impossible to solve from afar.
    – leymannx
    Aug 7 '18 at 12:03
  • Any other info I can provide to make it easier to solve?
    – coderama
    Aug 7 '18 at 12:18
  • What is massive? Each unique URL will result in a cache entry in that table, that is by design. As @4k4 wrote, you can set a lower limit manually, but the only thing that does is that clear out all entries over the limit by age. Until you run cron, it will still grow over that limit. If you have a lot of content, then you want it to be big because you want your content to be cached. 404 pages should already be limited to 1h by default. The uniqueness also covers query arguments, so it could also be query arguments, for a search, pager or someone might send a lot of requests.
    – Berdir
    Aug 7 '18 at 20:56
  • Another alternative is to use a cache backend like Redis or Memcache which have built-in limits and have more intelligent purging implementations (they can delete infrequently used entries and not just old ones)
    – Berdir
    Aug 7 '18 at 20:57
  • It was gaining 100 Mb a day, and never becoming less... ever. So day 1, 100mb, day 2, 200 mb, day 3, 300 mb etc. And it would basically become terabytes in size if I didn't manually clear it every couple of days. I wrote a hack to do this for me, but ideally I'd like to know why it's not clearing in the first place.
    – coderama
    Aug 8 '18 at 5:05
10

You can set a lower limit than the default 5000 for the number of cache items that are stored in the page cache bin:

settings.php:

$settings['database_cache_max_rows']['bins']['page'] = 500;

See this change record: Database cache bins are now fixed size — no more unlimited growth

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