Làm thế nào chúng ta có thể ngăn trình duyệt lưu vào bộ nhớ đệm trang ASPX?
Làm thế nào chúng ta có thể ngăn trình duyệt lưu vào bộ nhớ đệm trang ASPX?
Ngăn trình duyệt cache trang bằng HTTP header Cache-Control.
protected void Page_Load(object s, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetValidUntilExpires(false);
}
Hoặc chỉ thị trang: <%@ OutputCache Location="None" NoStore="true" %>.
[ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)]
public IActionResult Account() => View();
// Hoặc middleware/ minimal API
app.Use(async (ctx, next) =>
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.