oop123123
oop123123

Reputation: 45

Caching table at startup ASP.NET MVC Application

I have ASP.NET MVC application, where I keep all of drop down values in a table. So on average every page accesses this table 2-3 times. I want to cache (load into memory) this table on application startup.

Is there a way to do so? I have googled, but helpful topics found.

Thanks in advance.

Upvotes: 3

Views: 3211

Answers (2)

Ken Henderson
Ken Henderson

Reputation: 2828

Would loading it into a static variable do it for you?

You could populate it via the static constructor of whatever class your variable was contained in.

Sidenote: Have you tried just populating the drop down values dynamically on each page load? Was curious if this was a case of pre-optimizing that might not be necessary.

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039080

You could use the built-in cache. As far as the application startup is concerned you could use the Application_Start method in global.asax.

Upvotes: 3

Related Questions