Added a storage which compress only modified packages and invalidates caching automatically #657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request, beyond fix unit test errors, adds four templatetags for prefetching resources and a new storage which I called OptimizedPipelineStorage. This storage adds three new features:
It identifies which packages had removed/added/changed files and will compress only those which have modifications. When you have multiple packages, this will speed up the collectstatic process substantially.
After the compression, this storage produces a single md5 hash from the compressed files. This hash is appended to the resources' URL as a query parameter. Thus, when any package has modifications the compression will produce a new hash and, consequently, the cache's registries for your static files will be automatically invalidated.
It removes from the STATIC_ROOT the source files that were used to produce the compressed files. This is useful when you don't want to expose the raw versions of your javascript and css files.
I found this storage and the new templatetags very valuable for my necessities. I hope it serves to someone else too. Comments are welcome.