brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: nginx expires 30d sets browser caching for static files in one line

Nginx
~/tips/tip-nginx-expires-static-files

expires 30d;

Tells browsers to keep static files for 30 days and skip repeat downloads.

Static assets with versioned names should not be downloaded again on every visit.

location ~* \.(css|js|woff2|png|jpg|svg)$ {
    expires 30d;
}

expires 30d sends an Expires header and Cache-Control: max-age=2592000. Use it only for files whose name changes when the content changes, such as app.3f9c.js, because visitors keep the old copy for the whole month otherwise. expires epoch and expires -1 switch caching off. Check the result with curl -sI and read the Cache-Control line.

Further reading: ngx_http_headers_module: expires

Going deeper: 🛜 Guide: AdGuard Home + Tailscale (Secure Split-Horizon DNS)

More Nginx tips sudo certbot --nginx -d example.com -d www.example.com /data/nginx/custom/server_redirect.conf map $http_upgrade $connection_upgrade { proxy_intercept_errors on; proxy_redirect http://localhost:3000/ /app/; All Nginx tips (50) All topics

Link