使用 `<%@ OutputCache VaryByCustom="authenticated" %>` 依使用者驗證狀態分開快取使用者控件。
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (context.Request.IsAuthenticated) return "B"; // 已驗證
else return "C"; // 未驗證
}
頁面加入 `<%@ OutputCache Duration="600" VaryByParam="none" VaryByCustom="ietype" %>`,在 GetVaryByCustomString 中判斷 Request.Browser.Type 回傳不同字串,即可實現瀏覽器級別快取區隔。