I have this in my views.py
@cache_page(60 * 5)
def get_campaign_count(request):
return HttpResponse(
json.dumps({
'count': Campaign.objects.get_true_campaign_query().filter(dismissed=False).count()
},
cls=DjangoJSONEncoder
),
content_type='application/json')
Getting the count takes some time (20-40 seconds) each time it loads, so I decided to add caching to it with a 5 minute expiration time. My question is, is it possible to tell django to automatically re-cache the page during expiration? Otherwise another user would have to go through the 20-40 seconds wait before getting the response before other users benefit from the cache.