By design, the output cache is first checked for a cached copy of the page. If there is a cached copy, it is returned and nothing else is executed. In particular, no controller and no controller action is performed, checked, or performed. This only happens if the page is not cached.
You will need to change the cache provider so that it can quickly determine if the page can be potentially cached. Only if this is a cachable page, then it should go and check the distributed cache. This check cannot be based on OutputCacheAttribute
because they are not available during this part of the request processing. Instead, quickly check the URL, cookies, and other HTML header information.
source share