Improve performance on poor connections: local assets, gzip, caching

- Replace Tailwind CDN (~350KB) with purged local CSS (~22KB)
- Replace htmx unpkg CDN with local static file
- Add Gzip middleware (standard library, sync.Pool) for all responses
- Add Cache-Control: public, max-age=3600 for /static/* assets
- Reduce status polling interval from 5s to 30s
- Add scripts/build-css.sh for CSS regeneration after template changes
- Document in bible-local/operations.md and history.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikhail Chusavitin
2026-03-14 14:51:21 +03:00
parent c53c484bde
commit df5be91353
14 changed files with 1220 additions and 4 deletions

View File

@@ -163,6 +163,42 @@ xattr -d com.apple.quarantine /path/to/pfs-darwin-arm64
---
## Frontend Assets (Tailwind CSS)
Static assets are embedded into the binary from `web/static/`. CSS and JS are served locally —
no external CDN requests at runtime.
### Regenerate Tailwind CSS
Run this after adding new Tailwind utility classes to any HTML template:
```bash
scripts/build-css.sh
# or directly:
node_modules/.bin/tailwindcss -i tw-input.css -o web/static/tailwind.min.css --minify
```
First-time setup (requires Node.js):
```bash
npm install
```
`node_modules/` is excluded from git. `web/static/tailwind.min.css` **is** committed —
rebuilding is only needed when templates change.
### Files involved
| File | Purpose |
|------|---------|
| `tailwind.config.js` | Content paths for class scanning |
| `tw-input.css` | Tailwind input (base/components/utilities directives) |
| `web/static/tailwind.min.css` | Generated output — committed, embedded into binary |
| `web/static/js/htmx.min.js` | htmx — committed, embedded into binary |
| `scripts/build-css.sh` | Shortcut to regenerate CSS |
---
## Requirements
- Go 1.22+