jezdez/django_compressor — pull request #346 by pindia (2012-12-14 04:16:53+00:00)
Title: Add caching to CompilerFilter to not re-compile unchanged files

Currently django_compressor seems to re-run precompilers on each compression, even if files are completely unchanged. I haven't been able to stop this through any combination of existing caching options. In my large project, this has gotten to the point where it takes 10-15 seconds to load every page.

This patch adds caching directly to the `CompilerFilter` class. Before running the compiler, it computes a hash of the input contents and checks the compressor cache for a cached output. If not found, the compiler runs as normal and the output is saved to the cache for next time. Thus, only files that have actually changed are recompiled. When used in combination with a file-based caching backend to persist across server restarts, this greatly speeds up development.