views:

27

answers:

1

I am using django-storage's Mosso backend to store image files in the Rackspace CDN. However, I am facing very slow page loads due to the back and fourth of model.image_field.url lookups to the api. Does anyone know a good way to cache this value?

A: 

If you've already got memcached on your side, I suggest the memorised module:

http://github.com/1stvamp/memorised/

... which is a variant of the classic python-decorator memoize -- the memorized module eschews local dict caches for the memcache. "memorised" functions are almost as fast as memoized functions* plus their cache isn't tied to the lifecycle of the python interpreter.

I don't know thing one about rackspace cdn, but memorised makes my stuff measurably faster in a granular and magic-free way.

[*]: in my little bitty statistically-insignificant testing

fish2000