I’m using Django Cache to cache certain pages. I’m using the @vary_on_cookie decorator to allow logged in users to cache specific user details. However I need to clear the cache of the particular user for a particular page.
i.e. I need a way to generate the same key that the django middleware cache generates the key, using the cookies and the path etc. Then I can use the low level cache to clear the particular entry myself.
How do I go about doing this?
The function you are looking for is located in
django.middleware.cache:will return the following:
keep in mind that you might define your own key generation mechanism by setting the variable
KEY_FUNCTIONmanually.HTH!