This is a newbie question from someone who doesn’t know much about HTTP caching 🙂
I’m using Django with the @never_cache decorator.
Is there a way I can instruct the browser to cache the page unless the content has changed, in which case the browser should reload the page?
Thanks.
I disagree with Dominic and there is a very good reason to generate the page, see if it’s changed and throw it away if it hasn’t – and that’s to avoid the need to transfer the entire page over the internet. This only makes sense if your page is quite cheap to generate and is fairly large, but it can be a quick win.
The mechanism for doing this is the ETag header. Django has good support for this, just set USE_ETAGS in settings.py and you’ll get the benefit of returning 304 Not Modified responses where appropriate on all your pages.