ASP.NET在web浏览器缓存中包含cookie

ASP.NET在web浏览器缓存中包含cookie,asp.net,cookies,session-cookies,setcookie,httpcookie,Asp.net,Cookies,Session Cookies,Setcookie,Httpcookie,我有一个网站,询问用户的位置,然后将其存储在cookie中。我想在网站上添加缓存,以便对同一url/querystring/cookie的任何请求都将首先使用客户端的浏览器缓存。我可以通过在我的outputCacheProfiles中使用varyByCustom并为服务器上的每个请求创建自定义字符串来实现服务器缓存。在用户使用新位置更新cookie后,我无法找到任何方法强制用户请求每个页面的新版本,而不要求他们点击浏览器上的“刷新” 如何将cookie包含为web浏览器客户端缓存的依赖项? 下面

我有一个网站,询问用户的位置,然后将其存储在cookie中。我想在网站上添加缓存,以便对同一url/querystring/cookie的任何请求都将首先使用客户端的浏览器缓存。我可以通过在我的
outputCacheProfiles
中使用
varyByCustom
并为服务器上的每个请求创建自定义字符串来实现服务器缓存。在用户使用新位置更新cookie后,我无法找到任何方法强制用户请求每个页面的新版本,而不要求他们点击浏览器上的“刷新”

如何将cookie包含为web浏览器客户端缓存的依赖项?

下面是我目前正在做的工作,用于在服务器上缓存不同的url/querystring/cookie组合

在web.config中

<system.web>
...
    <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="DefaultCacheProfile" enabled="true" duration="60"  varyByCustom="latlon" varyByParam="None" />
        </outputCacheProfiles>        
      </outputCacheSettings>
    </caching>
下面是我如何创建我的cookie

System.Web.HttpCookie oCookie = new System.Web.HttpCookie(CookieSupport.CookieName);
oCookie.Values.Add("lat", data_Lat.ToString);
oCookie.Values.Add("lon", data_Lng.ToString);    
Response.Cookies.Add(oCookie);
public override string GetVaryByCustomString(System.Web.HttpContext context, string custom)
{

    if (custom.ToLower() == "latlon") {
        if (CookieSupport.CookieExists) {
            double lon = double.Parse(CookieSupport.CookieValueGet("lon"));
            double lat = double.Parse(CookieSupport.CookieValueGet("lat"));

            string varystring = string.Format("{0},{1},{2}", Request.QueryString, lat, lon);

            return varystring;
        } else {
            return Request.QueryString.ToString;
        }
    }

    return base.GetVaryByCustomString(context, custom);
}
System.Web.HttpCookie oCookie = new System.Web.HttpCookie(CookieSupport.CookieName);
oCookie.Values.Add("lat", data_Lat.ToString);
oCookie.Values.Add("lon", data_Lng.ToString);    
Response.Cookies.Add(oCookie);