1
votes

I'm used DB and filebased cache with my django 1.4.1 project. I have more than 100 000 elements that should be cached, they are caching for 48 hours. But elements in cache are disapearing too early and cache coverage is about 10%.

For example, main page should be generated only one time in 48 hours, but It get's from cache only 30% of hits, other 70% of requests doesn't find cached version and regenerates main page.

cache_time = 60*60*24*2
body_html = cache.get('index')
if not body_html:
    body_html = generate_page_html_content()
    cache.set('index', body_html, cache_time)
#do something with body_html

For db cache SELECT count(*) FROM cache; returned 224 cached items but there should be much more of them. What can be wrong?

1

1 Answers

0
votes

Here is the solution: https://docs.djangoproject.com/en/dev/topics/cache/#cache-arguments

I added MAX_ENTRIES option and set limit, that is suitable for me.