1

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.

ozgur
  • 2,549
  • 4
  • 25
  • 40
  • It makes the request to determine if the content has changed. If it gets a "notmodified" header in the response it will use the cached version. – Michael Mar 30 '16 at 15:30

1 Answers1

1

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
    // ...
});
Community
  • 1
  • 1
teo van kot
  • 12,350
  • 10
  • 38
  • 70