Knowledgebase

How to Enable Browser Caching for Static Assets in Nginx Print

  • 0

Boost Google PageSpeed and Core Web Vitals by caching images, CSS, and JS.

Step-by-Step Instructions

  1. Add an expires 30d; location block for static extensions.
  2. Disable access_log for static files to reduce disk I/O.
location ~* \.(jpg|jpeg|png|webp|gif|ico|css|js|woff2)$ {
  expires 30d;
  add_header Cache-Control "public, no-transform";
  access_log off;
}

Pro Tip: Use versioned filenames or query strings (?v=2) when updating cached CSS/JS.

Need assistance? Open a ticket in the A1 Client Area or contact our 24/7 NOC Engineering Team on WhatsApp at +1 (406) 229-9597.


Was this answer helpful?

« Back