2

I'm building a KPI monitoring web app. It used to work perfectly fine with a few users, but lately the load increased, causing problems with our backend systems. Some of them are very expensive to license, others are hard to scale mainframes.

It is very important for the business to never show data which is more that 10 min old. Ideally I'd like to call my backend once every 10 min, but only if there are active users.

My biggest problem currently is that most users start work at the same time and my app receives 30-40 requests in the matter of a few seconds.

How can I reliably solve this issue?

I've tried creating a static object in Global.asax.cs. That got very complex very fast, as I needed locking and a way to signal to pages that there is a backend info retrieval in progress.

I've also used CacheCow.Server in the past, but it's WebAPI only and it felt like a black box I don't really understand.

Can you give me an advice on how to proceed please?

1 Answers1

4

Have you tried using the OutputCache attribute? (The link is to older docs, but it's still valid).

using System.Web.Mvc;

namespace MvcApplication1.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        [OutputCache(Duration=600, VaryByParam="none")]
        public ActionResult Index()
        {
            return View();
        }

    }
}

The output of that action will be cached for the number of seconds specified, in this case, 10 minutes.

Michael Dunlap
  • 4,300
  • 25
  • 36
  • 3
    This will cache the HTML that is actually generated by this controller action, which seems like an appropriate form of caching for this particular issue. It does not cache the business data in any way (but again, that does not seem to be needed here). – Eric J. Jun 22 '15 at 23:00