私はアクションメソッドへのajax呼び出しを行うビューを持っています。Asp.net MVC 3キャッシング
$.ajax({
url: url to action,
type: 'GET',
cache: false,
dataType: 'html',
success: function(result) {
$("#divPatient").html(result);
$("#divPatient").show("blind", { }, 2000);
$("#loadingImage").hide();
PrepPatientHtml();
}
});
アクションメソッドは、表示されるようにhtmlを返します。サイトはSQLデータベースから動かされ、変更されたときにアクションの出力に影響が及ぶはずです。 NoCacheアクションフィルタを追加しました
public class NoCache : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
filterContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1));
filterContext.HttpContext.Response.Cache.SetValidUntilExpires(false);
filterContext.HttpContext.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
filterContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
filterContext.HttpContext.Response.Cache.SetNoStore();
base.OnResultExecuting(filterContext);
}
}
何らかの理由で、ビューをサポートしているデータベースが変更されたときにキャッシュが無効になることはありません。誰でも考えがありますか?ビューは非常に簡単です:
@using (Html.BeginForm("Save", "Home", FormMethod.Post, new { id = "frm" }))
{
<div style="padding: 10px;">
<h1 id="questionsHeader">@Model.FullName (@Model.Dob)</h1>
@for (var i = 0; i < Model.Episodes.Count; i++)
{
@Html.EditorFor(model => model.Episodes[i])
}
</div>
<div style="padding-top: 10px; border-top: solid 1px #666666; margin-top: 5px; text-align: right;">
<input type="submit" id="btnSaveAnswers" value="Save Answers" />
</div>
}
同じ結果を試しました。エンティティフレームワークが私のためにデータをキャッシュしているかのようです。 – jsteve81