tersejson 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -135,6 +135,61 @@ console.log(users[0].emailAddress); // Works transparently!
|
|
|
135
135
|
|
|
136
136
|
*At $0.09/GB egress, 10M requests/day = ~$1,000/month saved.*
|
|
137
137
|
|
|
138
|
+
## Why Gzip Isn't Enough
|
|
139
|
+
|
|
140
|
+
**"Just use gzip"** is the most common response to compression libraries. But here's the reality:
|
|
141
|
+
|
|
142
|
+
### Gzip Often Isn't Enabled
|
|
143
|
+
|
|
144
|
+
- **11%** of websites have zero compression (W3Techs)
|
|
145
|
+
- **60%** of HTTP responses have no text-based compression (HTTP Archive)
|
|
146
|
+
|
|
147
|
+
### Proxy Defaults Are Hostile
|
|
148
|
+
|
|
149
|
+
Most deployments put a reverse proxy (nginx, Traefik, etc.) in front of Node.js. The defaults actively work against you:
|
|
150
|
+
|
|
151
|
+
**NGINX:**
|
|
152
|
+
- `gzip_proxied` defaults to `off` — won't compress proxied requests
|
|
153
|
+
- `gzip_http_version` defaults to `1.1`, but `proxy_http_version` defaults to `1.0` — mismatch causes silent failures
|
|
154
|
+
- Official Docker nginx image ships with `#gzip on;` (commented out)
|
|
155
|
+
|
|
156
|
+
**Traefik (Dokploy, Coolify, etc.):**
|
|
157
|
+
- Compress middleware is NOT enabled by default
|
|
158
|
+
- Must explicitly add labels to every service:
|
|
159
|
+
```yaml
|
|
160
|
+
traefik.http.middlewares.compress.compress=true
|
|
161
|
+
traefik.http.routers.myrouter.middlewares=compress
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Kubernetes ingress-nginx:**
|
|
165
|
+
- `use-gzip: false` by default in ConfigMap
|
|
166
|
+
- Must explicitly configure in ingress-nginx-controller
|
|
167
|
+
|
|
168
|
+
### The Fix Requires DevOps
|
|
169
|
+
|
|
170
|
+
Enabling gzip properly requires:
|
|
171
|
+
```nginx
|
|
172
|
+
gzip on;
|
|
173
|
+
gzip_proxied any;
|
|
174
|
+
gzip_http_version 1.0;
|
|
175
|
+
gzip_types text/plain application/json application/javascript text/css;
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
That means DevOps coordination, nginx access, and deployment. In most orgs, the proxy is managed by a different team.
|
|
179
|
+
|
|
180
|
+
### TerseJSON Just Works
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
app.use(terse())
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
One line. Ships with your code. No proxy config. No DevOps ticket. Works whether gzip is enabled or not.
|
|
187
|
+
|
|
188
|
+
**If gzip is working:** You get 15-25% additional savings on top.
|
|
189
|
+
**If gzip isn't working:** You get 70-80% savings instantly.
|
|
190
|
+
|
|
191
|
+
Either way, you're covered.
|
|
192
|
+
|
|
138
193
|
## API Reference
|
|
139
194
|
|
|
140
195
|
### Express Middleware
|