Zest.

nginx: Gzip and caching static files

A short, tested nginx example for gzip and caching static files. Copy it and adjust the names and paths for your project.

nginx
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;

location ~* \.(js|css|png|jpg|svg|woff2)$ {
    expires 1y;
    add_header Cache-Control "public, immutable";
}

Find it in Zest

Search for “nginx gzip and caching static files” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More nginx examples

All nginx examples