John Doe
John Doe

Reputation: 3233

How to get rid of a MemoryCache object in MVC?

I have an MVC app where I am getting a XML file and loading into an object.

In my view I have several client/server operations and since MVC is stateless I stored the object into a MemoryCache (to prevent the constant loading of the XML file).

While this seems to work nicely, however my concern is how to remove this MemoryChache item when I am done?

If the user goes to different view then I want to remove this object.

However I don't know what event I could use to ensure this object gets removed.

Upvotes: 0

Views: 54

Answers (1)

John Doe
John Doe

Reputation: 3233

It appears that I can handle it with JQuery:

$(window).unload(function () {
    // Server call to clear MemoryCache
});

Upvotes: 1

Related Questions