From 24d6cf7047cfc7e4ce689389f58ffce87ee048ef Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 30 Aug 2026 18:46:25 +0200 Subject: [PATCH] perf: precompress heavy assets and self-heal missing gamedata originals (gzip_static) --- update-Nitrov3.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/update-Nitrov3.sh b/update-Nitrov3.sh index 84e6e55179..c388a28828 100755 --- a/update-Nitrov3.sh +++ b/update-Nitrov3.sh @@ -2000,6 +2000,7 @@ update_client() { fi mkdir -p "$NITRO_CLIENT/dist/custom-themes" [ ! -f "$NITRO_CLIENT/dist/custom-themes/index.json" ] && echo '{"themes":[]}' > "$NITRO_CLIENT/dist/custom-themes/index.json" + precompress_assets fix_perms return 0 } @@ -3507,6 +3508,24 @@ http_status() { if [ -n "$code" ]; then echo "$code"; else echo 000; fi } +# Re-generate .gz sidecars for the heavy static assets so nginx `gzip_static` +# serves them instantly (no per-request compression). Also restores any loose +# original that was left behind as only the .gz sidecar — a state that would +# otherwise make the origin 404 on those files. +precompress_assets() { + local root f base + for root in "$(dirname "${GAMEDATA_CONF_DIR:-/var/www/Gamedata/config}")" "${NITRO_CLIENT:-/var/www/Octane}/dist"; do + [ -d "$root" ] || continue + while IFS= read -r f; do + base="${f%.gz}" + [ -f "$base" ] || { gunzip -k "$f" && warn "Restored missing original: %s" "$base"; } + done < <(find "$root" -name "*.gz" -type f 2>/dev/null) + find "$root" -type f \( -name "*.js" -o -name "*.css" -o -name "*.wasm" -o -name "*.json" -o -name "*.jsonc" \) -size +20k -print0 2>/dev/null \ + | while IFS= read -r -d '' f; do gzip -k -f -6 "$f"; done + done + ok "$(_t "Assets compressed for fast serving")" +} + # TCP reachability probe for the websocket endpoint (curl cannot talk `wss://`). check_socket() { local url="$1" hostport host port @@ -3616,6 +3635,7 @@ cmd_fixlinks() { fi command -v redis-cli &>/dev/null && redis-cli FLUSHALL 2>/dev/null && ok "Redis flushed" || true fix_perms + precompress_assets info "$(_t "Done — links fixed. Test the client now.")" release_lock return 0