aspc/mainsite — pull request #4 by mattdahl (2013-10-02 06:42:32+00:00)
Title: Eatshop query optimization

RE: https://app.asana.com/0/192153543403/1436445080196

This PR enables caching on the eatshop page that significantly reduces the load time of the page. Instead of ~500 SQL queries executing on each page load, now there are fewer than 10.

There are a lot of commits in this PR because I went through a couple stages of caching mechanisms... First I just tried caching the individual queries, but I realized that was pretty inefficient. Then I attempted to use Django's `@cache_page` on the render methods in views.py but that caused the entire page to be cached, which led into trouble with the header persisting. This final implementation is just caching the specific business_hours_fragment.html templatetag, but there is some nastiness involved with trying to calculate the cache hash to invalidate it on save.

But it seems to be working locally from what I can tell so far... :)