openhatch

Issue565

Title Use cache-control headers so that anonymous pages are always cached by reverse proxies
Milestone later Priority bug
Waiting On Status chatting
Superseder Nosy List paulproteus
Assigned To Keywords performance

Created on 2011-08-22.22:55:57 by paulproteus, last changed 2011-11-10.00:41:15 by paulproteus.

Messages
msg2659 (view) Author: paulproteus Date: 2011-11-10.00:41:10
Not done
msg2372 (view) Author: paulproteus Date: 2011-08-22.22:55:56
Right now, we rely on Django's caching for performance. We use the django-
staticgenerator app to do some ad-hoc extra caching.

There are some pages which are accessed by users who are logged-in that we should 
be able to cache. Right now, if a request gets passed all the way to Django, we 
have Django generate the results.

But that is not the only way to do it. Instead, Django could simply indicate that 
the request has not been modified in the time since it was last cached.

The way this would work is:

* First time: Client connects to our transparent proxy and does a GET. Proxy has 
no data in the cache, so it asks the Django code. Our Django code returns the 
full response, as well as this HTTP header: "Cache-control: public, s-maxage=0, 
proxy-revalidate".

* Second time: Client connects to our transprent proxy and does a GET. Proxy has 
the page in its cache. Because the Django app said 'proxy-revalidate', the proxy 
must always ask the server if the cached version is valid. The proxy does the 
GET, but also adds a header: "If-Modified-Since:" plus the time that it did the 
GET that caused the data to be in the cache. Django app looks at all the models 
that it would have used, and if none were modified since the If-Modified-Since 
time, it says, "304 Not Modified". This is way faster than actually generating 
the page.

Thanks to Michael Stone for this concept.
History
Date User Action Args
2011-11-10 00:41:15paulproteussetstatus: unread -> chatting
messages: + msg2659
milestone: 0.11.10 -> later
2011-08-22 22:55:57paulproteuscreate