0

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.

1 Answer 1

1

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+).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.