OutputCache多个域名下会记录相同页面问题
2015-11-23 14:39
495 查看
[OutputCache(Duration = PresetLang.CACHE_DURATION, VaryByCustom = "HomeIndex")]
public ActionResult Index()
{
Response.Cache.SetOmitVaryStar(true);
}
Global.asax.cs
//已用户当前的URL作为缓存Key
public override string GetVaryByCustomString(System.Web.HttpContext context, string custom)
{
var urlCache = WebCache.Get<string>(context.Request.Url.Host);
if (urlCache == null)
{
urlCache = string.Format("{0}{1}", context.Request.Url.ToString(), Guid.NewGuid());
WebCache.Add<string>(context.Request.Url.Host, urlCache);
}
return urlCache;
//string requestUrl = context.Request.Url.ToString();
//return requestUrl;
}
public ActionResult Index()
{
Response.Cache.SetOmitVaryStar(true);
}
Global.asax.cs
//已用户当前的URL作为缓存Key
public override string GetVaryByCustomString(System.Web.HttpContext context, string custom)
{
var urlCache = WebCache.Get<string>(context.Request.Url.Host);
if (urlCache == null)
{
urlCache = string.Format("{0}{1}", context.Request.Url.ToString(), Guid.NewGuid());
WebCache.Add<string>(context.Request.Url.Host, urlCache);
}
return urlCache;
//string requestUrl = context.Request.Url.ToString();
//return requestUrl;
}
相关文章推荐
- 老鸟需要知道的一些php系统类函数
- php保留2位小数,只舍不入
- laravel5——command
- PHP面向对象基础实例
- PHP常用的预定义常量
- CreatPackageContext
- php 中文字符串截取
- PHP $_SERVER说明详解
- php设置编码格式的方法
- PHP实现简单爬虫-抓取网页url
- PHP - 验证码
- PHP程序中变量的使用范围
- PhpStorm使用技巧小结
- PHP - 验证类
- php判断字符串长度 strlen()与mb_strlen()函数
- PHP UTF-8和Unicode编号互转
- PHP中读写文件
- PHP读取xml方法介绍
- phpExcel常用方法详解大全
- FragmentPagerAdapter与FragmentStatePagerAdapter区别