1

We have a custom controller for some custom functionality which basically calls a web service to fetch some data, depending on certain input parameters from end users. We have enabled output caching for the website but don't want this particular functionality to be cached. Our page has the standard elements like header, footer, banner, etc which are served by CMS and then results are displayed via our custom controller.

In order to achieve this, we have tried using DxaNoOutputCache, NoCache, Cache with a duration of 1 but nothing seems to be working and the page/results get cached every time.

Any thoughts or any help would be appreciated.

  • Did you try this attribute? [NoCache] [OutputCache(NoStore = true, Duration = 0, VaryByParam = "*")] – Velmurugan Apr 17 at 21:07
  • Yes, we tried that (after noticing it in adminController) but we received an error when used "Nostore" saying "child actions cannot use that" and also the duration should be greater than 0. So we tried with [NoCache] [OutputCache(Duration = 1, VaryByParam = "*")] and it would still cache everything – GJin Apr 18 at 1:18
  • It's not mandatory to pass that attribute, what is the behavior if you are not passing? – Velmurugan Apr 18 at 6:10
  • Its still cached, it looks like "NoCache" has no affect – GJin Apr 18 at 15:07
  • 1
    Please edit your question to update your custom controller class? give some pointers to how your implementation you are trying access, enable trace logs to troubleshoot the issue, or run a web application in locally and try to debug? – Velmurugan Apr 18 at 17:02
2

Note that the DxaNoOutputCache attribute is intended to be used on View Models, not on Controllers.

The other cache attributes are not DXA-specific; these are general ASP.NET MVC attributes influencing the general ASP.NET MVC output caching behavior. See, for example: https://www.tutorialspoint.com/asp.net_mvc/asp.net_mvc_caching.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.