Leverage browser caching for Nginx, no css when reloading the page Leverage browser caching for Nginx, no css when reloading the page nginx nginx

Leverage browser caching for Nginx, no css when reloading the page


Take a look at Fiddler traces or Chrome dev tools.

A 304 would mean that the server responded with "not modified, use your local cache". If you clear your browser cache or do Shift + Refresh, you will get a 200 along with the body of the file. 304 on the contrary have zero body length.


I was getting the same issue.

Resolved it by placing:

location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {        expires 365d;}location ~*  \.(pdf)$ {        expires 30d;}

inside

location /static/

So the final config looks like

location / {        proxy_pass         http://app_servers;        proxy_redirect     off;        proxy_set_header   Host $host;        proxy_set_header   X-Real-IP $remote_addr;        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;        proxy_set_header   X-Forwarded-Host $server_name;        location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {            expires 365d;        }        location ~*  \.(pdf)$ {            expires 30d;        }    }

Reference: https://developers.google.com/speed/pagespeed/module/filter-cache-extend