代码之家  ›  专栏  ›  技术社区  ›  Blatfrig

基于URL更改OutputCache

  •  8
  • Blatfrig  · 技术社区  · 16 年前

    我已经得到了我想使用OutputCache指令缓存的页面。但是,我使用URL重写器模块将多个URL定向到此页面,每个URL具有不同的内容。

    2 回复  |  直到 16 年前
        1
  •  11
  •   Blatfrig    16 年前

    最后,这是很容易修复的。

    1. 将以下指令添加到需要缓存的页面:

      <

    2. 将此方法添加到global.asax文件中

      public override string GetVaryByCustomString(HttpContext context, string custom)
      {
          switch (custom.ToUpper())
          {
              case "RAWURL":
                  return context.Request.RawUrl;
      
              default:
                  return "";
          }
      }
      
        2
  •  0
  •   Justin Swartsel    16 年前

    响应缓存 . 您可以打开querystring变量,并根据具体情况设置属性 响应缓存 适当地。

    MSDN on Cache object
    Another helpful article from aspalliance.com