Reputation: 1495
So far I have easy solution:
@cache_page(60 * 60 * 24)
def myview()
Which works fine. What bothers me though, that what if table in database changes (someone uploades data), then cached view should be re-evaluated. Moreover, since I rarely and irregularly have DB updates, I would like to not specify the 60 * 60 * 24 (once a day), but be it infinity unless DB's table changes (or maybe entire DB changes).
What do I do? I'm sure there is easy solution.
Upvotes: 0
Views: 410
Reputation: 2263
That's how it works. In order to invalidate the cache you could use a signal to clear certain cache entry when certain model instance is saved.
https://docs.djangoproject.com/en/1.8/topics/signals/
As for setting an infinite cache, use None
as timeout and it will never expire (Django 1.7+).
Upvotes: 1