3

I call this action using Fiddler/Postman and in the first time it gets the response from the server side and the other requests from the cache, works!

    [Route("Menu/GetSideBarMenuItems")]
    [ResponseCache(Duration = oneWeek, VaryByQueryKeys = new[] { "sideBarMenuItemType"})]
    public async Task<IActionResult> GetSideBarMenuItems(LU_SideBar_Ajax sideBarMenuItemType)

I copied the exact same headers and body(in Fiddler you can drag and drop to the composer) and just changed the url to location/peru/cusco and it doesn't cache it, never.

    [Route("Location/{countrySlug}/{citySlug?}")]
    [ResponseCache(Duration = 120)]
    public async Task<IActionResult> LocationPage(string countrySlug, string citySlug = null)

The headers of the second response are:

enter image description here

I tried to move app.UseResponseCaching(); to be the first middleware but it didn't work and also I read all existing documentation and couldn't understand what am I doing wrong, I downloaded Microsoft samples and the caching worked, but not in my project.

I tried to send the request with Fiddler & Postman(disabled the cache header) and Incognito mode.

Any Idea?

Offir
  • 3,252
  • 3
  • 41
  • 73
  • Hi @Offir, it works fine in my project. Could you pls check if your Startup.cs/ Program.cs configure other settings for cache? – Rena Jun 28 '22 at 02:10

0 Answers0