From 57b7ada2e4446afa817fe3bc0d76b99100cffd47 Mon Sep 17 00:00:00 2001 From: Shubham Padia Date: Fri, 5 Sep 2025 12:44:50 +0000 Subject: [PATCH] help: Pre compress astro build files before serving. This way nginx doesn't have to compress it every time. --- pnpm-lock.yaml | 9 +++++++++ puppet/zulip/files/nginx/zulip-include-frontend/app | 5 +---- starlight_help/astro.config.mjs | 6 ++++++ starlight_help/package.json | 1 + version.py | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0fb13c9ca0..ebd856bcc6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -549,6 +549,9 @@ importers: astro: specifier: ^5.1.2 version: 5.13.5(@types/node@22.18.1)(encoding@0.1.13)(jiti@2.5.1)(rollup@4.50.0)(terser@5.44.0)(typescript@5.9.2)(yaml@2.8.1) + astro-compressor: + specifier: ^1.1.2 + version: 1.1.2 hast-util-from-html: specifier: ^2.0.3 version: 2.0.3 @@ -3265,6 +3268,10 @@ packages: resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==} hasBin: true + astro-compressor@1.1.2: + resolution: {integrity: sha512-BsX6ypOkRff2g7e5vA47Vlpq9MfVxAo4pXzfkJvXTSzzrSYvf8m3e0lbyGK6eReSzWcAPXymOTIoooqDX1BTlA==} + engines: {node: '>=22.15.0 <23.0.0 || >=23.8.0'} + astro-eslint-parser@1.2.2: resolution: {integrity: sha512-JepyLROIad6f44uyqMF6HKE2QbunNzp3mYKRcPoDGt0QkxXmH222FAFC64WTyQu2Kg8NNEXHTN/sWuUId9sSxw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -12948,6 +12955,8 @@ snapshots: astring@1.9.0: {} + astro-compressor@1.1.2: {} + astro-eslint-parser@1.2.2: dependencies: '@astrojs/compiler': 2.12.2 diff --git a/puppet/zulip/files/nginx/zulip-include-frontend/app b/puppet/zulip/files/nginx/zulip-include-frontend/app index bb99079647..d83007e883 100644 --- a/puppet/zulip/files/nginx/zulip-include-frontend/app +++ b/puppet/zulip/files/nginx/zulip-include-frontend/app @@ -36,10 +36,7 @@ location ~ ^(/help(?:/[^/]+)*)/+$ { location /help { alias $help_alias; - gzip on; - gzip_min_length 1000; - gzip_proxied expired no-cache no-store private auth; - gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + gzip_static on; include /etc/nginx/zulip-include/headers; add_header Access-Control-Allow-Origin *; add_header Timing-Allow-Origin *; diff --git a/starlight_help/astro.config.mjs b/starlight_help/astro.config.mjs index f7d182f3b2..c645278a3a 100644 --- a/starlight_help/astro.config.mjs +++ b/starlight_help/astro.config.mjs @@ -4,6 +4,7 @@ import * as fs from "node:fs"; import starlight from "@astrojs/starlight"; import {defineConfig, envField} from "astro/config"; +import compressor from "astro-compressor"; import Icons from "unplugin-icons/vite"; // https://astro.build/config @@ -73,6 +74,11 @@ export default defineConfig({ }, }, integrations: [ + compressor({ + gzip: true, + brotli: false, + zstd: false, + }), starlight({ title: "Zulip help center", favicon: "../static/images/favicon.svg", diff --git a/starlight_help/package.json b/starlight_help/package.json index 78143f9879..098705e3e5 100644 --- a/starlight_help/package.json +++ b/starlight_help/package.json @@ -14,6 +14,7 @@ "@astrojs/starlight": "^0.35.1", "@iconify-json/fa": "^1.2.1", "astro": "^5.1.2", + "astro-compressor": "^1.1.2", "hast-util-from-html": "^2.0.3", "hast-util-to-html": "^9.0.5", "mdast-util-to-string": "^4.0.0", diff --git a/version.py b/version.py index abc359bee2..f47b4d065a 100644 --- a/version.py +++ b/version.py @@ -49,4 +49,4 @@ API_FEATURE_LEVEL = 425 # historical commits sharing the same major version, in which case a # minor version bump suffices. -PROVISION_VERSION = (348, 0) # bumped 2025-09-10 to downgrade sharp +PROVISION_VERSION = (348, 1) # bumped 2025-09-10 to add astro-compressor.