diff --git a/nomad/api.py b/nomad/api.py
index 22c5e831a4a94398b9b77d35b2ac613b418cabb8..c70cb989e2b12353096768eaf9a890512c275127 100644
--- a/nomad/api.py
+++ b/nomad/api.py
@@ -644,7 +644,17 @@ def get_calc(upload_hash, calc_hash):
     try:
         archive = ArchiveFile(archive_id)
         arhchive_path = archive.os_path
-        return send_file(arhchive_path, attachment_filename=os.path.basename(arhchive_path))
+
+        rv = send_file(
+            arhchive_path,
+            mimetype='application/json',
+            as_attachment=True,
+            attachment_filename=os.path.basename(arhchive_path))
+
+        if config.files.compress_archive:
+            rv.headers['Content-Encoding'] = 'gzip'
+
+        return rv
     except KeyError:
         abort(404, message='Archive %s does not exist.' % archive_id)
     except FileNotFoundError:
diff --git a/tests/test_api.py b/tests/test_api.py
index 580e1e59160fe26fab2154c5fb15a8d40d91e461..7543c0cc8cf48b9d66622a362203056b03238eea 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -1,6 +1,7 @@
 import pytest
 import time
 import json
+import zlib
 import re
 from mongoengine import connect
 from mongoengine.connection import disconnect
@@ -153,7 +154,7 @@ def test_processing(client, file, mode, worker, mocksearch, test_user_auth, no_w
     upload_id = upload['upload_id']
 
     upload_cmd = upload['upload_command']
-    headers = dict(Authorization='Basic %s' % re.search(r'.*-HAuthorization: Basic ([^\s]+).*', upload_cmd).group(1))
+    headers = dict(Authorization='Basic %s' % re.search(r'.*Authorization: Basic ([^\s]+).*', upload_cmd).group(1))
     upload_endpoint = '/uploads/%s' % upload_id
     upload_file_endpoint = '%s/file' % upload_endpoint
 
@@ -266,6 +267,12 @@ def test_repo_calcs_user_invisible(client, example_elastic_calc, test_other_user
 
 def test_get_archive(client, archive, no_warn):
     rv = client.get('/archive/%s' % archive.object_id)
+
+    if rv.headers.get('Content-Encoding') == 'gzip':
+        json.loads(zlib.decompress(rv.data, 16 + zlib.MAX_WBITS))
+    else:
+        json.loads(rv.data)
+
     assert rv.status_code == 200
 
 
diff --git a/tests/test_files.py b/tests/test_files.py
index 69a1371f6b10c842b219a27872c99e8a31c56c90..3abcebd7aec7b40bf623340c0e4024afe57aac4e 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -75,7 +75,7 @@ def archive_config(monkeypatch, request):
         config.files.uploads_bucket,
         config.files.repository_bucket,
         config.files.archive_bucket,
-        request)
+        request.param)
     monkeypatch.setattr(config, 'files', new_config)
     yield