- 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>
20 lines
459 B
Go
20 lines
459 B
Go
package middleware
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// StaticCache sets Cache-Control headers for static assets (/static/*).
|
|
// 1-hour cache allows browsers to reuse JS/CSS across page navigations
|
|
// without re-downloading on every request.
|
|
func StaticCache() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
if strings.HasPrefix(c.Request.URL.Path, "/static/") {
|
|
c.Header("Cache-Control", "public, max-age=3600")
|
|
}
|
|
c.Next()
|
|
}
|
|
}
|