compressor still output a file when memcached is used?
Is it correct behaviour for django-compressor to still output the compressed file in the COMPRESS_ROOT folder even when Memcached is enabled?
In the docs it says:
For production sites it is strongly recommended to use a real cache backend such as memcached to speed up the checks of compressed files.
My cache in Django is set up correctly and working.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': '127.0.0.1:11211',
}
}
What I'm seeing is, with memcached enabled, if I delete the STATIC_ROOT folder, django-compressor does not regenerate the js/css files anymore. Anyone else see this bahaviour?
I faced similar problems. To fix it, I created a small django management command in my django app to clear memcache, which I run during deployment.
I suppose if you rely on memcache for many things, you might want to be more fine-grained, but for us blowing away the whole cache is fine.
Code as follows:
from django.core.cache import cache
from django.core.management.base import BaseCommand, CommandError
import getpass
class Command(BaseCommand): help = 'Flush the memcache (or whatever the default caching system is)'
def handle(self, *args, **options):
if ("flush_all" in dir(cache._cache)):
cache._cache.flush_all()
print "Cache Flush Done."
else:
print "No-op ... this cache type has no flush"
链接地址: http://www.djcxy.com/p/71088.html