From 1f992dba64bf16f25fc0f58fff67ee820e60c24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Fri, 10 Apr 2026 22:55:50 +0200 Subject: [PATCH 1/5] Enable gzip compression in nginx for RDF and JSON content types Adds gzip_types covering application/json, SPARQL results, RDF serializations (Turtle, RDF/XML, LD+JSON, TriG, N-Quads, N-Triples), XML, CSS, JS, and SVG. Primarily reduces client.xsl.sef.json transfer size from ~11.8MB to ~2-3MB. Co-Authored-By: Claude Sonnet 4.6 --- docker-compose.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 4c644b561..e8c89a3eb 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -193,6 +193,24 @@ configs: client_max_body_size ${MAX_CONTENT_LENGTH:-2097152}; + gzip on; + gzip_types + application/json + application/ld+json + application/rdf+xml + application/sparql-results+json + application/sparql-results+xml + application/trig + application/n-quads + application/n-triples + application/xml + text/turtle + text/css + text/javascript + application/javascript + image/svg+xml; + gzip_min_length 1024; + # server with optional client cert authentication server { listen 8443 ssl; From 2c74d8989c46fa79fbb7982598ae621c9f28c1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Fri, 10 Apr 2026 23:19:05 +0200 Subject: [PATCH 2/5] Add gzip HTTP tests for SEF file and RDF/XML response Co-Authored-By: Claude Sonnet 4.6 --- http-tests/misc/gzip-rdfxml.sh | 25 +++++++++++++++++++++++++ http-tests/misc/gzip-sefjson.sh | 18 ++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100755 http-tests/misc/gzip-rdfxml.sh create mode 100755 http-tests/misc/gzip-sefjson.sh diff --git a/http-tests/misc/gzip-rdfxml.sh b/http-tests/misc/gzip-rdfxml.sh new file mode 100755 index 000000000..049b8f6a4 --- /dev/null +++ b/http-tests/misc/gzip-rdfxml.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +initialize_dataset "$END_USER_BASE_URL" "$TMP_END_USER_DATASET" "$END_USER_ENDPOINT_URL" +initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL" +purge_cache "$END_USER_VARNISH_SERVICE" +purge_cache "$ADMIN_VARNISH_SERVICE" +purge_cache "$FRONTEND_VARNISH_SERVICE" + +# Test that nginx gzip compression is active for RDF/XML dynamic content + +response=$(curl -i -k -s \ + -H "Accept-Encoding: gzip" \ + -H "Accept: application/rdf+xml" \ + "$END_USER_BASE_URL") + +if ! echo "$response" | grep -qi "Content-Encoding: gzip"; then + echo "Content-Encoding: gzip not found on RDF/XML response" + exit 1 +fi + +if ! echo "$response" | grep -q "HTTP/.* 200"; then + echo "RDF/XML request did not return 200 OK" + exit 1 +fi diff --git a/http-tests/misc/gzip-sefjson.sh b/http-tests/misc/gzip-sefjson.sh new file mode 100755 index 000000000..3d277267f --- /dev/null +++ b/http-tests/misc/gzip-sefjson.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Test that nginx gzip compression is active for static JSON (SEF file) + +response=$(curl -i -k -s \ + -H "Accept-Encoding: gzip" \ + "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/xsl/client.xsl.sef.json") + +if ! echo "$response" | grep -qi "Content-Encoding: gzip"; then + echo "Content-Encoding: gzip not found on client.xsl.sef.json" + exit 1 +fi + +if ! echo "$response" | grep -q "HTTP/.* 200"; then + echo "client.xsl.sef.json did not return 200 OK" + exit 1 +fi From 268eea6095d2763360710e355e5322334d758f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Fri, 10 Apr 2026 23:51:59 +0200 Subject: [PATCH 3/5] Fix gzip HTTP tests: use -D - to avoid binary body, add owner cert for RDF/XML Co-Authored-By: Claude Sonnet 4.6 --- http-tests/misc/gzip-rdfxml.sh | 3 ++- http-tests/misc/gzip-sefjson.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/http-tests/misc/gzip-rdfxml.sh b/http-tests/misc/gzip-rdfxml.sh index 049b8f6a4..156ffdaca 100755 --- a/http-tests/misc/gzip-rdfxml.sh +++ b/http-tests/misc/gzip-rdfxml.sh @@ -9,9 +9,10 @@ purge_cache "$FRONTEND_VARNISH_SERVICE" # Test that nginx gzip compression is active for RDF/XML dynamic content -response=$(curl -i -k -s \ +response=$(curl -k -s -D - -o /dev/null \ -H "Accept-Encoding: gzip" \ -H "Accept: application/rdf+xml" \ + --cert "$OWNER_CERT_FILE:$OWNER_CERT_PWD" \ "$END_USER_BASE_URL") if ! echo "$response" | grep -qi "Content-Encoding: gzip"; then diff --git a/http-tests/misc/gzip-sefjson.sh b/http-tests/misc/gzip-sefjson.sh index 3d277267f..00abef966 100755 --- a/http-tests/misc/gzip-sefjson.sh +++ b/http-tests/misc/gzip-sefjson.sh @@ -3,7 +3,7 @@ set -euo pipefail # Test that nginx gzip compression is active for static JSON (SEF file) -response=$(curl -i -k -s \ +response=$(curl -k -s -D - -o /dev/null \ -H "Accept-Encoding: gzip" \ "${END_USER_BASE_URL}static/com/atomgraph/linkeddatahub/xsl/client.xsl.sef.json") From 1da256cdc514975393247c3d8c9e239123a13f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Sat, 11 Apr 2026 12:43:08 +0200 Subject: [PATCH 4/5] nginx conf fix --- docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose.yml b/docker-compose.yml index e8c89a3eb..ec02bdeee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -194,6 +194,7 @@ configs: client_max_body_size ${MAX_CONTENT_LENGTH:-2097152}; gzip on; + gzip_proxied any; gzip_types application/json application/ld+json From 66decad4e8df5d4822cfc53c43827ba5a82eb7fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martynas=20Jusevi=C4=8Dius?= Date: Sat, 11 Apr 2026 17:52:34 +0200 Subject: [PATCH 5/5] Fix gzip RDF/XML test: create item and append data instead of testing root container Co-Authored-By: Claude Sonnet 4.6 --- http-tests/misc/gzip-rdfxml.sh | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/http-tests/misc/gzip-rdfxml.sh b/http-tests/misc/gzip-rdfxml.sh index 156ffdaca..3744752b3 100755 --- a/http-tests/misc/gzip-rdfxml.sh +++ b/http-tests/misc/gzip-rdfxml.sh @@ -7,13 +7,39 @@ purge_cache "$END_USER_VARNISH_SERVICE" purge_cache "$ADMIN_VARNISH_SERVICE" purge_cache "$FRONTEND_VARNISH_SERVICE" -# Test that nginx gzip compression is active for RDF/XML dynamic content +# Test that nginx gzip compression is active for RDF/XML dynamic content. +# Create an item, append enough data to exceed gzip_min_length, then retrieve it as RDF/XML. + +add-agent-to-group.sh \ + -f "$OWNER_CERT_FILE" \ + -p "$OWNER_CERT_PWD" \ + --agent "$AGENT_URI" \ + "${ADMIN_BASE_URL}acl/groups/writers/" + +item=$(create-item.sh \ + -f "$AGENT_CERT_FILE" \ + -p "$AGENT_CERT_PWD" \ + -b "$END_USER_BASE_URL" \ + --title "Gzip test item" \ + --slug "gzip-test" \ + --container "$END_USER_BASE_URL") + +printf '@prefix ex: .\n +<> ex:prop1 "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore." ;\n + ex:prop2 "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo." ;\n + ex:prop3 "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." ;\n + ex:prop4 "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est." .\n' \ +| post.sh \ + -f "$AGENT_CERT_FILE" \ + -p "$AGENT_CERT_PWD" \ + -t "text/turtle" \ + "$item" response=$(curl -k -s -D - -o /dev/null \ -H "Accept-Encoding: gzip" \ -H "Accept: application/rdf+xml" \ - --cert "$OWNER_CERT_FILE:$OWNER_CERT_PWD" \ - "$END_USER_BASE_URL") + -E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \ + "$item") if ! echo "$response" | grep -qi "Content-Encoding: gzip"; then echo "Content-Encoding: gzip not found on RDF/XML response"