Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何将AJAX Json数据缓存5分钟?_Jquery_Wcf_Caching - Fatal编程技术网

Jquery 如何将AJAX Json数据缓存5分钟?

Jquery 如何将AJAX Json数据缓存5分钟?,jquery,wcf,caching,Jquery,Wcf,Caching,我能够缓存AJAX数据结果,但无法指定缓存时间。 以下是部分代码: [OperationContract(Name = "Prepopulate_GetData")] [WebGet(UriTemplate = "/Prepopulate/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] string GetData(); Client call: functio

我能够缓存AJAX数据结果,但无法指定缓存时间。 以下是部分代码:

[OperationContract(Name = "Prepopulate_GetData")]
[WebGet(UriTemplate = "/Prepopulate/GetData", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string GetData();

Client call:

function GetData() {
  $.ajax
  ({
      url: "svc/Prepopulate.svc/Prepopulate/GetData"
    , cache: true
...
注意:我无法使用AspNetCacheProfile属性,因为此web应用程序中仍使用.NET3.5。该属性仅适用于.Net 4.0>

我也在WCF中尝试了下面的代码,但没有成功:

System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
System.Web.HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);
System.Web.HttpContext.Current.Response.Cache.SetNoStore();
有什么想法吗?
谢谢你

你有-1,这意味着在创建时过期,也删除了SetNoStore,你会尝试:System.Web.HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(5));System.Web.HttpContext.Current.Response.Cache.SetCacheability(System.Web.HttpCacheability.Private);如果你把我的回答作为答案而不是投票的话,那就太好了。。。