3

I'm building a ASP.net MVC 4 system that is very load intensive and want to use the OutputCache attribute on the two key pages. The OutputCache has the desired effect in making the pages very quick but I need to be able to control when they expire, as changes in the data must be reflected on the site promptly.

Here an example of my code - I'm trying to cache the page for 10 mins or until the database table changes. I've got the SQLDependency working OK.

[OutputCache(Duration = 600, SqlDependency = "myDb:myTable")]
public ActionResult Index()
{
    // Do Stuff                     
    return View();
}

[OutputCache(Duration = 600, SqlDependency = "myDb:myTable", VaryByParam = "id")]
public ActionResult Details(int id)
{
    // Do Stuff                     
    return View();
}

There are 54 different details pages. When something in the database table changes I need the cache for the index and all the details pages to be expired. Currently the cacheing is working but not expiring in the way I'd expect.

My questions are

  1. What is the relative priorities of the different parameters in the `OutputCache' attribute?
  2. Should my current configuration work correctly?

Any help is very much appreciated.

Tom Styles
  • 1,098
  • 9
  • 20

1 Answers1

0

Take a look at the following link:

SQL Cache Dependency

Note the following for your IIS user permissions:

GRANT SUBSCRIBE QUERY NOTIFICATIONS TO "TESTSERVER\ASPNET"
will
  • 121
  • 1
  • 1
  • 9