From 14e74d15c1a03d8a6eda0f6d6bdddf1b87d492ce Mon Sep 17 00:00:00 2001 From: David Larlet Date: Fri, 6 Dec 2024 10:21:14 -0500 Subject: [PATCH] chore: always gzip geojson in S3 storage --- umap/settings/base.py | 12 ++++++++++++ umap/storage.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/umap/settings/base.py b/umap/settings/base.py index 1e069b54..c4f59096 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -182,6 +182,18 @@ STORAGES = { "BACKEND": "umap.storage.UmapManifestStaticFilesStorage", }, } +# Add application/json and application/geo+json to default django-storages setting +# in order to gzip our datalayers geojson files. +GZIP_CONTENT_TYPES = [ + "text/css", + "text/javascript", + "application/javascript", + "application/x-javascript", + "image/svg+xml", + "application/json", + "application/geo+json", +] + # ============================================================================= # Templates diff --git a/umap/storage.py b/umap/storage.py index 677bf7de..dd862a1b 100644 --- a/umap/storage.py +++ b/umap/storage.py @@ -72,6 +72,8 @@ class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage): class UmapS3(S3Storage): + gzip = True + def get_reference_version(self, instance): metadata = self.connection.meta.client.head_object( Bucket=self.bucket_name, Key=instance.geojson.name