Reputation: 2719
On my controller
[OutputCache(Duration = 60, Location = OutputCacheLocation.Any)]
I have this attribute. In my view I have
<div id="hot-topics-replacement" url="@Url.Action("IndexPartial", "Topics")"></div>
And this is JQuery code
var url = $("#hot-topics-replacement").attr("url");
$("#hot-topics-replacement").load(url, function () { ResizeHotTopics(); });
It always makes a request to server. I was expecting at least it caches to browser (I am testing on Chrome) but it doesn't do it.
I don't know where is my mistake.
EDIT SOLVED
When I check Response Headers, I observed that between last modified date and expiration date there is just 10 seconds instead of 60. Now I made the Cache Duration
200 seconds and it works.
As far as I understood, there is something fishy about date times between server and client.
Upvotes: 1
Views: 101
Reputation: 12491
There is no mistake.
I suppose your problem is in your scenario how do you use this function. If you press F5 in browser client cache dissapears. Check this answer.
Anyway i recommend you to check maby anywhere in your project client cache dissabled. Somethig like this:
$.ajaxSetup ({
// ...
cache: false
// ...
});
Upvotes: 1