This directives not working => Nginx ignores this cache control directive of 30d:

location ~* \.(ico|css|js|gif|jpeg|jpg|png|woff|ttf|otf|svg|woff2|eot)$ {
root
/var/app/current/app/dist/client/; #if i comment this out it, my css and js files are not found...
expires
30d;
access_log off
;
log_not_found off
;
add_header
Pragma "public";
add_header
Cache-Control "public";
}


Reason: Pagespeed interfering with ‘Expires’ directive on static files

Because PageSpeed is loading the files directly from the filesystem, no custom headers will be set.

Example of Nginx directive of pagespeed module:

pagespeed LoadFromFile "http://www.example.com/static/" "/var/www/static/";

This directive tells PageSpeed to load all resources whose URLs start with http://www.example.com/static/  from the filesystem under /var/www/static/. For example, http://www.example.com/static/images/foo.png will be loaded from the file /var/www/static/images/foo.png. However, http://www.example.com/bar.jpg will still be fetched using HTTP. If you have resources that need to be served with custom headers, such as Cache-Control: private, you need to exclude them from LoadFromFile. For resources PageSpeed rewrites in-place it will set a 5-minute cache lifetime by default, which you can adjust by changing LoadFromFileCacheTtlMs.

Solution: Add this setting to the domain.conf:

pagespeed LoadFromFile "http://example.com" "/var/www"
pagespeed LoadFromFileCacheTtlMs 31556926000;

Source: https://github.com/apache/incubator-pagespeed-ngx/issues/1418