diff --git a/compressor/templatetags/compress.py b/compressor/templatetags/compress.py index 6b6322f..215e969 100644 --- a/compressor/templatetags/compress.py +++ b/compressor/templatetags/compress.py @@ -23,8 +23,22 @@ class CompressorNode(template.Node): if in_cache: return in_cache else: - output = compressor.output() - cache.set(compressor.cachekey, output, 86400) # Rebuilds the cache once a day if nothing has changed. + # do this to prevent dog piling + in_progress_key = 'django_compressor.in_progress.%s' % compressor.cachekey + in_progress = cache.get(in_progress_key) + if in_progress: + while cache.get(in_progress_key): + sleep(0.1) + output = cache.get(compressor.cachekey) + else: + cache.set(in_progress_key, True, 300) + try: + output = compressor.output() + cache.set(compressor.cachekey, output, 2591000) # rebuilds the cache every 30 days if nothign has changed. + except: + from traceback import format_exc + raise Exception(format_exc()) + cache.set(in_progress_key, False, 300) return output @register.tag diff --git a/setup.py b/setup.py index 259c5c6..78df013 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ README = read('README.rst') setup( name = "django_compressor", - version = "0.5", + version = "0.5.1", url = 'http://github.com/mintchaos/django_compressor', license = 'BSD', description = "Compresses linked and inline javascript or CSS into a single cached file.",