Django Compressor Offline Inheritance

This issue is specifically for a production site using Django Compressor. I want this to work when COMPRESS_OFFLINE = True, so that I can pre-compress all the css site files before proceeding to production.

I would like, as part of base.html, to do the equivalent of this:

{% compress %} {% block css %} {% endblock %} {% endcompress %} 

so all my css blocks in files that expand the base are compressed. This is basically the case that I don’t need to add the {% compress%} tags to all of my child templates.

There are several similar problems in Qaru, but I did not find a good solution for this when compressing offline (i.e. using the Django Compressor compression control command). Ambient compression tags work fine when COMPRESS_OFFLINE = False. Has anyone found a way to disable this work?

I list several similar threads that seem to be related to non-standalone solutions. The links in the second thread indicate that there were problems with inheritance while working with Django Compressor in standalone mode, but they may have been fixed:

Django compressor and template inheritance

Does a django compressor work with template inheritance?

+6
source share
1 answer

You use the compress offline to run this technology, but until you configure the caching correctly, django-compressor will not be re-compressed for each request, unless the resources have been changed.

I used this technique so that users can use lesscss to expand the theme of the site and use our mixes, etc. This is a bit wonky to work, but (in my experience so far) it is completely stable when configured correctly and does not introduce a significant wait time for the request after it is compressed for the first time.

You can set up a service like pingdom , blamestella , or a new relic to go to different pages to ensure that the compressed assets are always in the cache (they track uptime, but work for it too)

0
source

Source: https://habr.com/ru/post/918602/


All Articles