title: ASP.NET Core 2.0 Web API Response Caching
body: <p>I am trying to implement response caching in my web api using the "Microsoft.AspNetCore.ResponseCaching" package.</p>
  
  <p>I am using Postman to test the application and validate headers etc.</p>
  
  <p>The correct headers are generated with the specified max-age but postman seems to request the response from the api and not using the cache. The response time does not vary at all and if I debug the controller I can see that it gets hit by the request every time.</p>
  
  <p>Startup class ConfigureServices (along with other stuff):</p>
  
  <pre><code>services.AddResponseCaching();
  </code></pre>
  
  <p>Startup class Configure (along with other stuff):</p>
  
  <pre><code> app.UseResponseCaching();
  
   app.UseMvc();
  </code></pre>
  
  <p>Controller Action:</p>
  
  <pre><code>    [HttpGet("{employeeNr}", Name = EmployeeAction)]
      [ResponseCache(Duration = 50)]
      [Produces(typeof(EmployeeDto))]
      public async Task&lt;IActionResult&gt; GetEmployee(SpecificEmployeeParameters parameters)
      {
          if (!await _employeeRepository.EmployeeExists(parameters.EmployeeNr)) return NotFound();
  
          if (!_typeHelperService.TypeHasProperties&lt;EmployeeDto&gt;(parameters.Fields))
              return BadRequest();
  
          var entity = await _employeeRepository.GetEmployee(parameters.EmployeeNr);
  
          var result = Mapper.Map&lt;EmployeeDto&gt;(entity);
          return Ok(result.ShapeData(parameters.Fields));
      }
  </code></pre>
  
  <p>Response headers from Postman:</p>
  
  <pre><code>cache-control →private,max-age=50
  content-type →application/json; charset=utf-8
  date →Wed, 30 Aug 2017 11:53:06 GMT
  </code></pre>