Reduce media bandwidth: compress uploads, add long-lived cache headers, gzip API

- Resize/re-encode every uploaded image server-side (posts, avatars, stories,
  shop products/logo, chat messages) via a shared sharp-based optimizer —
  caps dimensions to what's actually displayed and re-compresses in place,
  cutting a typical raw camera photo by ~90% with no visible quality loss
- Cap uploaded video resolution/bitrate (re-encode only when above 1280px/
  ~2.5Mbps) alongside the existing faststart step; apply faststart+cap to
  story and chat videos too (previously stored completely raw)
- Add long-lived Cache-Control to all /storage static routes so clients stop
  re-downloading unchanged media on every request
- Add gzip/brotli compression for JSON API responses (feed/explore/chat)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
payacom
2026-09-15 17:55:09 +03:30
parent 26979057d7
commit e1abb40cc6
14 changed files with 316 additions and 27 deletions

View File

@@ -16,6 +16,7 @@
"axios": "^1.6.7",
"bcryptjs": "^2.4.3",
"body-parser": "^1.20.2",
"compression": "^1.8.2",
"connect-redis": "^10.0.0",
"cors": "^2.8.5",
"dotenv": "^16.4.5",