title: Nginx configuration to cache angular app files
body: <p>I have the following configuration to run an angular.js app, which works fine.</p>
  
  <pre><code>location / {
      root   /usr/share/nginx/html;
      index  index.html;
      expires -1;
      add_header Pragma "no-cache";
      add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
      try_files $uri $uri/ /index.html =404;
  }
  </code></pre>
  
  <p>But when I add cache</p>
  
  <pre><code>location ~* \.(jpg|jpeg|png|gif|swf|svg|ico|mp4|eot|ttf|otf|woff|woff2|css|js)$ {
    add_header Cache-Control "max-age=86400, must-revalidate, s-maxage=2592000";
  }
  </code></pre>
  
  <p>The files are not longer accesibles</p>
  
  <pre><code>[error] 5#5: *1 open() "/etc/nginx/html/scripts/vendor-1568b32f3e.js" failed (2: No such file or directory), client: 87.63.75.163, server: localhost, request: "GET /scripts/vendor-1568b32f3e.js HTTP/1.1", host: "myapp", referrer: "http://myapp/auth/login"
  </code></pre>
  
  <p>Not sure why is trying to get the resources from <code>/etc/nginx/html/</code> when the root path is <code>/usr/share/nginx/html</code></p>