1

We have two controllers with OutputCaching, one work fine, second one doesn't cache...

Example of working controller:

    [OutputCache(Duration = 1, VaryByParam = "idc,key")]
    public dynamic Get(string idc, string key)
    {

        string coins = idc;
        string size = key;
        try
        {
            Models.api.dicebets bets = new Models.api.dicebets();
            return bets.LastBets(coins, size);
        }
        catch
        {
            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid request");
        }
    }

And example of similar controller with non-working OutpuCache:

    [OutputCache(Duration = 3)]
    public dynamic Get()
    {
        try
        {
            Models.api.dicebets bets = new Models.api.dicebets();
            return bets.HighRolls();
        }
        catch
        {
            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid request");
        }
    }

I have already tried all combinations of OutputCache settings like:

[OutputCache(Duration = 3, VaryByParam = "None")]
[OutputCache(Duration = 3, VaryByParam = "*")]
[OutputCache(Duration = 3, VaryByParam = "")]

None seems to work....

2
  • Out of curiosity why the Duration is so low ? Can you increase in both cases and test Remember it is in seconds. Also the result of an action will only be cached if the response doesn't include a cookie - see here stackoverflow.com/questions/20027813/… Commented Aug 21, 2016 at 17:29
  • I get around 30 request a second (and data changes on average every 3 seconds), thats why its so low. At current setting I should only get 20 database queries execution a minute, but I get 1800. Response doesn't include any cookies... Commented Aug 21, 2016 at 18:05

1 Answer 1

1

We solved it by using third party caching solution: Strathweb.CacheOutput

Sign up to request clarification or add additional context in comments.

1 Comment

Strathweb.CacheOutput was useful in our project, but we've outgrown it and need a more full-featured solution. github.com/aliostad/CacheCow is a more active and complete caching solution for both ASP.NET Framework and ASP.NET Core.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.