Beyond the SQL: Cacheing

  1. Customization
  2. Beyond the SQL
  3. Modifying models

http://docs.djangoproject.com/en/1.0/topics/cache/

Once you get really into the power of a framework like Django, you’ll start using it to add really cool features you would never have had the time for if you had to code them from scratch. Some of those really cool features will end up taking more time than your server can afford. Django also has a cacheing mechanism that you can use to cache expensive tasks. For example, looking at that custom autoLink filter, you might discover, after adding a thousand topics, that auto linking text takes too long.

When your tests show you that some feature is taking too much time and causing requests to queue on the server, you can either cache the entire page, or cache portions of the page.

If you want to use cacheing, the first thing you need to do is modify your settings.py file.

CACHE_BACKEND = 'file:///Users/jerry/Desktop/Django/Blog/cache?max_entries=500'

The “max_entries” value is the maximum number of caches Django will create before it starts throwing out entries. When that number of caches are created, Django will arbitrarily remove about a third of the caches.

Make sure that the folder you’re using exists; in this case, there needs to be a “cache” folder inside the Blog folder I’ve made for testing.

  1. Customization
  2. Beyond the SQL
  3. Modifying models