标签: outputcache

ASP.NET MVC缓存因控制器操作参数而异

有什么办法可以使用outputcache属性通过控制器动作参数来改变缓存?我们有varybyparam,如果我的参数以REST方式嵌入到URL中,则无法使用.

asp.net-mvc caching outputcache

2
推荐指数
2
解决办法
4882
查看次数

如何确保永远不会缓存动态生成的javascript文件?

我有一个动态生成的javascript文件,我想确保它永远不会被浏览器缓存.我目前的方法是简单地将(新)guid附加到每个页面视图上的脚本标记中的url.

例如:

<script type="text/javascript" src="/js/dynamic.js?rand=979F861A-C487-4AA8-8BD6-84E7988BD460"></script>
Run Code Online (Sandbox Code Playgroud)

我的问题是......这是实现目标的最佳方式吗?

作为参考,我使用的是ASP.NET MVC 2,并且由于控制器操作而生成javascript文件.

javascript asp.net-mvc caching outputcache

2
推荐指数
1
解决办法
1276
查看次数

如何在GetVaryByCustomString中访问asp.net mvc路由值?

我在.NET 3.5下运行一个asp.net mvc 2站点,我想GetVaryByCustomString在Global.asax的处理程序中访问路由值.我不清楚如果HttpContext传递给函数,如何(如果有的话)访问特定的路由值.

供参考,这是签名 GetVaryByCustomString

public override string GetVaryByCustomString(HttpContext context, string custom)
{
    // how do I get at route values here from context?
}
Run Code Online (Sandbox Code Playgroud)

有人能指出我正确的方向吗?

asp.net asp.net-mvc outputcache

2
推荐指数
1
解决办法
1268
查看次数

ASP.NET MVC - 在客户端缓存页面

我有这样缓存的代码:

[OutputCache(Duration="3600", Location=OutputCacheLocation.Client)]
Run Code Online (Sandbox Code Playgroud)

现在,我不知道这个输出缓存是如何工作的.它究竟在哪里保留页面的副本?什么是之间的差异OutputCacheLocation.ClientOutputCacheLocation.Browser

asp.net-mvc outputcache asp.net-mvc-3

2
推荐指数
1
解决办法
4094
查看次数

当我在输出缓存中使用它或缓存错误时,VaryByCustom不工作吗?

我花了一整天来弄清楚问题,但我不能:这是问题:在操作上我有输出缓存属性:

[OutputCache(Duration = 600, VaryByParam = "*", VaryByCustom = "User")]
Run Code Online (Sandbox Code Playgroud)

我也像这样重写了Global.asax:

public override string GetVaryByCustomString(HttpContext context, string arg)
{
    if (arg == "User")
    {
        return "User=" + context.User.Identity.Name;
    }

    return base.GetVaryByCustomString(context, arg);
}
Run Code Online (Sandbox Code Playgroud)

但是当我第一次登录时它会缓存值,然后当我尝试注销并再次以不同的用户身份登录时,我会看到之前的缓存值.在调试时,我检查了Identity.Name为第一个用户返回正确的结果,对于第二个用户,它是"admin",它是"kate"

c# asp.net-mvc caching outputcache

2
推荐指数
1
解决办法
3020
查看次数

为什么页面在一个URL上使用来自另一个URL的缓存页面?

背景

我是ASP.NET的新手,也是缓存概念的新手.我希望对于那些知道自己正在做的人来说,这里的问题显而易见.

使用MCMS 2002,我构建了一个template.aspx页面,该页面接收"person_id"查询字符串并相应地构建页面.我工作的学校的几个不同部门正在使用这个模板来展示教师的传记.这一切都正常工作.

问题

当我尝试缓存页面时,问题就开始发生了.当一个人在一个部门的页面上访问person_id = 16175,然后访问不同部门页面上的相同数字生物,它会加载缓存页面而不是重建它.那么问题在于它拥有所有错误的部门品牌.例如:

http://health.usf.edu/medicine/obgyn/facstaf/profiles.htm?person_id=16175 http://health.usf.edu/medicine/surgery/surgery_bios.html?person_id=16175

它与person_id相同,但URL明显不同.如果模板识别不同的URL并忽略缓存,那将是很好的.我假设问题在于这两个页面都是在后端使用相同的aspx页面构建的.这是aspx页面中的OutputCache位:

<%@ OutputCache Duration="86400" Location="Server" VaryByParam="person_id; section" VaryByCustom="CMSPosting" VaryByHeader="Referer" %>
Run Code Online (Sandbox Code Playgroud)

我想我在这里做错了什么.希望对于知道自己正在做的人来说,这是显而易见的.如果您需要更多信息,请不要犹豫.谢谢!

asp.net caching outputcache

1
推荐指数
1
解决办法
421
查看次数

IIS 7输出缓存 - 识别缓存的文件列表

我们可以获取IIS7中输出缓存的URL列表吗?

我试图弄清楚它在我们的服务器中的使用效率.

请参阅显示性能计数器的附加截图. 性能计数器

iis-7 caching outputcache performancecounter

1
推荐指数
1
解决办法
2361
查看次数

VaryByCustom和模型绑定

我有一个类我模型绑定,我想使用它的输出缓存.我找不到一种方法来访问绑定对象GetVaryByCustomString

例如:

public class MyClass
{
    public string Id { get; set; }
    ... More properties here
}

public class MyClassModelBinder : DefaultModelBinder
{
   public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
   {
      var model = new MyClass();
      ... build the class       
      return model;
    }
}
Run Code Online (Sandbox Code Playgroud)

我在Global.cs中设置了绑定器

ModelBinders.Binders.Add(typeof(MyClass), new MyClassModelBinder());
Run Code Online (Sandbox Code Playgroud)

然后像这样使用输出缓存.

[OutputCache(Duration = 300, VaryByCustom = "myClass")]
public ActionResult MyAction(MyClass myClass)
{
   .......

public override string GetVaryByCustomString(HttpContext context, string custom)
{
   ... check we're working with 'MyClass'

   var routeData = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc outputcache model-binding

1
推荐指数
1
解决办法
468
查看次数

如何在Glimpse"Views"选项卡上解释Check Cache和找到的列?

在调查慢速视图渲染的过程中,我正在查看"视图"选项卡,并试图找出哪些用户控件被缓存以及哪些用户控件没有缓存.

通常第一个条目显示如下:

| Path                     | Check Cache | Found  | Details            |
|--------------------------|-------------|--------|--------------------|
|~/Path/To/UserControl.ascx| true        |  false | Not found in cache |
|~/Path/To/UserControl.ascx| false       |  true  | key    | value     |

无论任何缓存指令如下所有用户控件都以相同的方式显示:

OutputCache Duration="3600" VaryByParam="none" Shared="True"

是瞥见还是我搞砸了输出缓存指令?

asp.net-mvc outputcache glimpse

1
推荐指数
1
解决办法
432
查看次数

如果页面被缓存,为什么不创建会话?

问题:当从缓存中提取请求的aspx页面时,为什么没有创建会话(和会话cookie)?

背景资料

我做了很多谷歌搜索,但我找不到任何表明这是预期的行为.我们期望的行为是始终生成新的会话/ cookie,无论所请求的页面是否从缓存中拉出.

我们使用以下代码缓存页面.(.NET 3.5,IIS 7.5)

Response.Cache.SetExpires(DateTime.Now.AddMonths(1));
Response.Cache.SetCacheability(HttpCacheability.Server);
Response.Cache.SetVaryByCustom("IsLoggedIn");
Response.Cache.VaryByParams["*"] = true;
Response.Cache.SetValidUntilExpires(true);
Response.AddCacheItemDependency("Pages");
Run Code Online (Sandbox Code Playgroud)

任何相关信息将不胜感激.

asp.net session outputcache iis-7.5

1
推荐指数
1
解决办法
677
查看次数