the-blue-alliance/the-blue-alliance — pull request #1025 by fangeugene (2014-05-13 23:40:33+00:00)
Title: Cachebusters!

Putting this up to get feedback.

This is a first attempt at properly invalidating cached responses to allow us to a) set memcache to not expire and b) cache responses in the datastore. This will make the site faster, cheaper to host, and can reduce the data transferred to our upcoming mobile apps (using the `If-Modified-Since` header).

This PR sets the memcache expiration for the API v2 controller responses to be infinity and invalidates the entries if any model within a particular controller's response gets updated. It does this by checking for reference keys in the manipulators, and if the model becomes dirty, makes a call to `helpers/cache_clearer.py` which defines which controllers are affected. If a model gets deleted, a similar process occurs. What this means is that all interactions with the datastore MUST go through the manipulators.

Currently, the only models I'm dealing with are Award, Event, EventTeam, Match, and Team.

Todo: `CACHE_VERSION` is now a class variable instead of an instance variable, so all of those need to be changed in all controllers that extend the CacheableHandler (which is like 90% of our controllers).