clintecker / django-chunks

Think of it as flatpages for small bits of reusable content you might want to insert into your templates and manage from the admin interface.
http://github.com/clintecker/django-chunks
BSD 3-Clause "New" or "Revised" License
304 stars 101 forks source link

cache key can be invalid #1

Open carljm opened 14 years ago

carljm commented 14 years ago

The Chunk key field is a CharField, which can take almost any kind of character data, including Unicode, spaces, whatever.

In the templatetag, the chunk key is used as part of the cache key. If using memcached with python-memcached, even spaces are illegal in a cache key. This causes 500 errors.

My first solution was to slugify the chunk key before using it as cache key. This works, but raises the possibility of two overly-similar (but still unique) chunk keys slugifying to the same cache key and stomping over each other's cache. The only way this would really work is if chunks gained an actual SlugField with uniqueness enforced.

So my second solution (found in my fork) was to rip out the direct caching support entirely. IMO there's no reason for django-chunks to have its own (buggy) cache support, when its just as easy (and more flexible) to wrap calls to the chunk tag with Django's built-in template fragment caching tags.

igorsobreira commented 12 years ago

+1 to remove the cache support. Just use the template fragment caching.

Also, today it caches the Chunk object, not just the content string. This just makes the cache bigger than necessary.