You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2022/05/23 20:24:08 UTC

[airavata] 01/02: AIRAVATA-3622 Force revalidation for non-hashed static files

This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata.git

commit fe009e7112a6328e3523e51a20e59a59719eeaab
Author: Marcus Christie <ma...@apache.org>
AuthorDate: Mon May 23 16:06:31 2022 -0400

    AIRAVATA-3622 Force revalidation for non-hashed static files
---
 .../ansible/roles/django/templates/django-ssl-vhost.conf.j2      | 9 +++++++++
 dev-tools/ansible/roles/django/templates/django-vhost.conf.j2    | 8 ++++++++
 2 files changed, 17 insertions(+)

diff --git a/dev-tools/ansible/roles/django/templates/django-ssl-vhost.conf.j2 b/dev-tools/ansible/roles/django/templates/django-ssl-vhost.conf.j2
index 71b5323968..2c2f73f3b2 100644
--- a/dev-tools/ansible/roles/django/templates/django-ssl-vhost.conf.j2
+++ b/dev-tools/ansible/roles/django/templates/django-ssl-vhost.conf.j2
@@ -62,6 +62,15 @@
     <Directory {{ doc_root_dir }}/static>
     Require all granted
     AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
+
+    # Force browser to revalidate cached static resources
+    Header set Cache-Control "no-cache"
+    # Workaround for ETag bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=45023#c22
+    RequestHeader edit "If-None-Match" '^"((.*)-gzip)"$' '"$1", "$2"'
+    # If file has a content hash, cache for a year
+    <FilesMatch "\.[0-9a-f]{8}\.(css|js)$">
+        Header set Cache-Control "max-age=31536000, public"
+    </FilesMatch>
     </Directory>
 
     Alias /media/ {{ airavata_django_checkout }}/django_airavata/media/
diff --git a/dev-tools/ansible/roles/django/templates/django-vhost.conf.j2 b/dev-tools/ansible/roles/django/templates/django-vhost.conf.j2
index e5c4398198..db95fb6e01 100644
--- a/dev-tools/ansible/roles/django/templates/django-vhost.conf.j2
+++ b/dev-tools/ansible/roles/django/templates/django-vhost.conf.j2
@@ -39,6 +39,14 @@
     <Directory {{ doc_root_dir }}/static>
     Require all granted
     AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
+
+    Header set Cache-Control "no-cache"
+    # Workaround for ETag bug: https://bz.apache.org/bugzilla/show_bug.cgi?id=45023#c22
+    RequestHeader edit "If-None-Match" '^"((.*)-gzip)"$' '"$1", "$2"'
+    # If file has a content hash, cache for a year
+    <FilesMatch "\.[0-9a-f]{8}\.(css|js)$">
+        Header set Cache-Control "max-age=31536000, public"
+    </FilesMatch>
     </Directory>
 
     Alias /media/ {{ airavata_django_checkout }}/django_airavata/media/