9

I'm fixing a bug with ASP.NET OutputCache and it's driving me insane. We want caching on the server, but it does not appear to work (it did a while ago, in an older version of our app, but we discovered the bug by accident recently).

Locally, I just cannot get the caching to work on the server-side. Using this attribute:

[OutputCache(CacheProfile = "MyProfile", Location = OutputCacheLocation.Server)] // doesn't work

Now, based on a few things I've read by googling around, here is possibly relevant information:

  • Output caching is enabled in IIS (localhost)
  • I DO use an AuthorizeAttribute (a custom one with inheritance). I've debugged towards this specifically, and I'm 95% confident this is not the cause.
  • I've fiddled around with various VaryByParams values, nothing works.
  • Caching does work client-side.

I've opened a perfmon session and added some counters from the Web Service Cache group, All I see is that there are cached URL's but the cache is missed:

perfmon graph

The bigger problem/bug we're facing now is that OutputCache is not working at all right now. We were able to fix that by specifying VaryByParams="" (an empty string). That did it for the client. But it doesn't work server-side yet.

I'm actually checking whether it works or not by placing a debug breakpoint in the action that should be cached. It gets hit everytime, which should mean the cache is not hit.

MarioDS
  • 12,895
  • 15
  • 65
  • 121
  • I had a similar issue and it was a problem with the cache profiles. If I didn't use a cache profile and instead plugged the values directly into the attributes contructor it worked. Have you tried that? – heymega Oct 15 '15 at 10:36
  • @heymega I tried it, and it doesn't make a difference. – MarioDS Oct 15 '15 at 11:09
  • @MarioDS:I'm running into the same problem. Did you manage to solve this? – user1107799 Apr 12 '17 at 12:26
  • @user1107799 Not that I remember. I guess we moved on to more important issues. – MarioDS Apr 12 '17 at 12:32

1 Answers1

0

From http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/improving-performance-with-output-caching-cs:

There is no guarantee that content will be cached for the amount of time that you specify. When memory resources become low, the cache starts evicting content automatically.

If the available memory resources on your server are low enough during your testing, the cache will evict content immediately. I'm sure it could even refuse to put your content in the cache.

gpersell
  • 84
  • 1
  • 10