2

I have my startup class configured like this:

public void ConfigureServices(IServiceCollection services)
{
    services.AddResponseCaching();    
    ...
}

public void Configure(IApplicationBuilder app)
{
    app.UseResponseCaching();
    ...
}

And my controller is like this:

[HttpGet]
[ResponseCache(Duration = 30)] //I normally have a policy here but used duration as an example
[Authorize("Policy_1")]
[Authorize(LocalApi.PolicyName)]
public IActionResult Get()
{
   ...
}

If I add a breakpoint on my controller method and use postman to send a request the breakpoint is hit and I can see the Cache Control key within the response headers:

enter image description here

If I send the request again the breakpoint IS hit (within the duration).

However, if I remove the Authorize attributes and the auth token from my request everything works as expected.

The authentication and authorization have been set up using identity server 4.

And just to confirm 'Send no-cache header' is off within postman.

So, the question is what do I need to add to get response caching working with identity server 4?

Sun
  • 4,458
  • 14
  • 66
  • 108

0 Answers0