title: Nginx Caching for Rest API
body: <p>I have created a Spring Boot project. I have to cache one Rest API call:</p>
  
  <blockquote>
    <p>GET localhost:8080/parts</p>
  </blockquote>
  
  <p>For that I have used <code>nginx</code>. But it is not working : every time I call the API, that call is going to backend. My configuration file is given below.</p>
  
  <p><strong>/usr/local/etc/nginx/nginx.conf</strong></p>
  
  <pre><code>http {
      include            mime.types;
      default_type       application/octet-stream;
      sendfile           on;
      keepalive_timeout  65;
  
      error_page   500 502 503 504  /50x.html;
  
      proxy_cache_path /var/log/oms levels=1:2 keys_zone=webcache:10m inactive=1d max_size=2000m;
      proxy_cache_min_uses 1;
  
      #upstream backend_server {
      # server localhost:8080;    
      #}
  
      server {
          listen 80;
          server_name localhost;
  
          location /parts {
              proxy_pass  http://localhost:8080/parts;
              proxy_cache webcache;
          }
  
          #location /{
          #    proxy_pass http://localhost:8080;
          #    proxy_cache webcache;
          #}
      }
  
      include servers/*;
  }
  </code></pre>