Skip to content

Commit

Permalink
[feature] Added static files minification and cache invalidation #216
Browse files Browse the repository at this point in the history
Fixes #216
  • Loading branch information
pandafy committed Dec 2, 2020
1 parent b0e6095 commit 9d72093
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tasks/pip.yml
Expand Up @@ -177,6 +177,21 @@
tags:
- molecule-idempotence-notest

- name: Install static minification dependencies
pip:
name:
- django-pipeline~=2.0.0
- django-compress-staticfiles~=1.0.1b
state: latest
virtualenv: "{{ virtualenv_path }}"
virtualenv_python: "{{ openwisp2_python }}"
virtualenv_site_packages: yes
retries: 5
delay: 10
register: result
until: result is success
notify: reload supervisor

- name: Install uwsgi
pip:
name: uwsgi
Expand Down
13 changes: 13 additions & 0 deletions templates/openwisp2/settings.py
Expand Up @@ -322,6 +322,19 @@
}
}

# HTML minification with django pipeline
INSTALLED_APPS.append('pipeline')
MIDDLEWARE.append('pipeline.middleware.MinifyHTMLMiddleware')
PIPELINE = {
'PIPELINE_ENABLED': True
}

# static files minification and invalidation with django-compress-staticfiles
STATICFILES_STORAGE = 'compress_staticfiles.storage.CompressStaticFilesStorage'
# GZIP compression is handled by nginx
BROTLI_STATIC_COMPRESSION = False
GZIP_STATIC_COMPRESSION = False

{% if openwisp2_sentry.get('dsn') %}
RAVEN_CONFIG = {{ openwisp2_sentry|to_nice_json }}
{% endif %}
Expand Down

0 comments on commit 9d72093

Please sign in to comment.