[ckan-discuss] CKAN caching decorator

William Waites william.waites at okfn.org
Fri Sep 3 16:27:50 BST 2010


 (Apologies to those on the list not familiar with
python, pylons etc., this message is intended for
the developers)

As we continue to struggle with load on the main
CKAN application server, I've implemented a decorator
that works basically like beaker_cache

It has two major differences:

  1. It sets cache-control headers to support an
      external cache like squid (or varnish if properly
      configured).

  2. It takes as an argument a test() function that
      must return the last_modified time for the
      resource. If last_modified > last_rendered, then
      the cache is invalidated and the document
      re-rendered.

It can be tricky to get this right, so I would like some
more eyes on it before I look at actually *using* the
decorator on the various CKAN controllers.

The code is in ckan/lib/cache.py
The tests are in ckan/tests/functional/test_cache.py

Cheers,
-w

-- 
William Waites           <william.waites at okfn.org>
Mob: +44 789 798 9965    Open Knowledge Foundation
Fax: +44 131 464 4948                Edinburgh, UK

RDF Indexing, Clustering and Inferencing in Python
		http://ordf.org/



More information about the ckan-discuss mailing list