11 Things I Wish I Knew About Django Development Before I Started My Company

Pick the right AJAX/JSON mechanism: Unless you want to do a full page reload with every HTTP request (which is completely ok, but SO 1995) you are going to want to send some data to the server using AJAX. The problem you will quickly hit is Django does not have a built in JSON HTTP response, so you are going to have to either man up and roll your own (good luck) or copy someone else smarter than you (this is what I did). Here is adecorator that works great, and this response is superb also

.. Use Gunicorn instead of Apache for your webserver

Django Cache Versioning

But there are some problems with this approach. For one, the first (uncached) request still takes the full 3.5 seconds.

.. Django supports “versioning” of cache records. If you specify a version number in your cache.set(key, value, version=my_version) call, then a corresponding cache.get(key, version=some_other_version) call will not return any data. Using versioning, we can change things around and store the user’s current ‘version’ in the cache. When we want to get the cached data set, we specify the user’s cached version number. In this way, we are able to invalidate old cache entries without searching through the cache for all of a user’s cached items. An example will help clarify: