I've tried a lot of things, and they all failed. My Django (2.0) website has some pages which take a lot of time to generate. I want to keep this pages in the database cache of the Django server until the database changed. My goal:
- Have pages ready in database cache
- Serve users the cached pages
- Don't save these pages as cache in the browser (the browser can't know if the page needs to be re-generated)
- Keep .js files etc as cache in browser
- Don't use browser cache when using the browser 'back' button to go back to the calculation heavy page
The closest I got was to enable database caching, enabled per-site caching, and using cache.clear() on receiving post_save and post_delete signals. But still, if I pressed 'back' in my browser, the local cache was used (so no request was send to the server). I tried to fix this by adding @never_cache to the view, but this also prevented caching in the middleware...