问题标签 [donut-caching]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
154 浏览

asp.net-mvc - DonutOutputCache 不适用于图像

我有一个 ASP.NET MVC 控制器操作,如下所示:

配置文件如下所示:

由于将DonutOutputCache我用来渲染的图像添加到我的浏览器现在不会加载。我可以在 Fiddler 跟踪中看到一个较大的二进制文件正在进入浏览器,但我似乎无法让它呈现。

删除DonutOutputCache使图像再次出现。

我试过清除缓存等。有什么想法吗?

0 投票
2 回答
2550 浏览

c# - 使用 mvcdonutcaching ASP.NET MVC 缓存 _Layout

在我的 ASP.NET MVC 项目中,我在共享_Layout.cshtml文件的导航菜单中有一个登录子菜单,如果用户已登录,则显示用户信息,如果未登录,则显示注册/登录选项。登录子菜单是我的共享文件夹中的部分视图,名为_LoginPartial

虽然我大量缓存了各种控制器的几个动作,但出于显而易见的原因,我想实现甜甜圈缓存,_Layout这样_LoginPartial就不会被缓存。我正在使用mvcdonutcaching库来完成此操作(在此答案@Html.Action中建议),它提供了一些具有附加bool excludeFromParentCache属性的重载。

因此,我创建了一个LayoutController带有UserAuth返回的操作_LoginPartial

..在_Layout我想要_LoginPartial出现的文件中,我将 mvcdonutcachingHtml.Action重载称为:

为了测试这一点,我在my 的操作OutputCache上设置了一个持续时间较长的,但如果我按照以下步骤操作:IndexFAQController

  • 登录
  • 导航到 /faq
  • 登出
  • 导航到 /faq

/faq 仍然显示我已登录。

我在这里想念什么?这是 mvcdonutcaching 在实际 HTML 中的输出:

更新:我也尝试将菜单移动_LoginPartial到位于视图中的部分视图中LayoutController- 问题仍然存在。

0 投票
1 回答
1852 浏览

c# - MVCDonutCaching - 如何删除子动作缓存 MVC Donut Caching

我正在使用这个MVCDonutCaching Nuget 包,因为在教程中他们说这可以通过子操作来实现。

这个问题对我不起作用,或者我没有正确理解它。

如果有人知道如何使用标准OutputCache属性删除子缓存,那也没关系!

我已经搜索过这个,但我找不到它。看这里的一个例子:

HomeController(主页)的索引操作:

NewsController 的 ChildAction:

HomeController 的索引视图:

为了清除缓存,我的应用程序中有一个管理区域,其中包含一个控制器和一个动作,用于更新子动作存储的数据。因此,当更新新闻文章时。缓存应在主页上刷新。

在该操作中,我有以下代码:

我尝试了多个版本,但没有运气。有谁能够帮助我?

0 投票
0 回答
132 浏览

asp.net-mvc - Avoid donut caching when user is logged in as admin in Forms Authentication?

I would like to avoid caching if the user is logged in with forms authentication in the admin group.

I have overridden the cache attribute and have applied it at the controller level. However, the method NonAdmin does not get called via the validationcallback!

How can I achieve non-caching when the user is logged in?

0 投票
1 回答
222 浏览

asp.net - Caching in ASP.NET MVC with uncachable forms

I'm doing donut caching with the MVCDonutCaching library.

Background to donut caching using this library:
The way it works, is you can cache a view, but exclude part of it from being cached, i.e. the "donut hole". You do this by having the uncachable stuff as a partial view, which is rendered by a child action. Then in the view you call that child action Html.RenderAction(.... This way everything but that child action will be cached.

Problem:
I need to cache a view, which contains a form. Problem is the form includes an AntiForgeryToken, which obviously should not be cached.

An obvious solution is to make that form a "donut hole", and render it via a child action. But, it needs complex viewmodel data, and child actions ony accept primitive types as arguments, otherwise I get serialization errors.

What is a good way around this?

0 投票
2 回答
610 浏览

c# - Mvc Donut Caching 以编程方式禁用缓存

我在我的项目中使用MvcDonutCaching并寻找一种方法来全局禁用缓存以在调试/测试期间提供帮助。

我在文档中找不到任何关于如何实现这一点的示例,尽管我确实找到了CacheSettingsManagerwhich 暴露了一个IsCachingEnabledGlobally属性,但是 this 是readonly.

CacheSettingsManager也没有任何允许我配置此设置的构造函数。有没有办法配置这个设置?

有一个替代解决方案可能有效(丑陋),但它绝对是最后的手段,不应该真的有必要:

然后在我的控制器操作上使用它:

有没有正确的方法来做到这一点?

0 投票
1 回答
926 浏览

c# - 如何使用 c# mvc 和 Varnish 进行甜甜圈缓存?

我添加到清漆配置

}

在我的 mvc 应用程序中,我有一个 childaction

并添加了一个请求头

但是 Varnish 一直在缓存整个页面。

我想念什么?我在浏览器中注意到请求标头 X-Esi 不存在。还清漆正确删除标签<esi:include

GetHour 中的代码非常简单,只需从 SQL Server 中检索一个小数。

0 投票
1 回答
798 浏览

asp.net-mvc - 从 MVC 5 中的 OutPutCache 中删除 ChildAction?

我正在使用 MVC 5.2.3 开发一个网站,它有一个顶部菜单栏,_Layout.cshtml其中包含登录的用户信息。就像用户的全名一样,所以它不应该被缓存。
为了从 OutPutCache 中排除此菜单,我为它创建了一个子操作。

之后,我安装了MvcDonutCachingnuget 包并按_Layout.cshtml如下方式使用它:

但是,它不起作用,如果有人登录,它的 FullName 会出现在所有客户端的顶部菜单栏中。

我应该如何从 MVC 中删除此子操作OutPutCache

0 投票
1 回答
381 浏览

asp.net-mvc - 如何在 ASP MVC 中将局部视图设置为甜甜圈孔

我已经从 GitHub 安装了 mvcdonutcaching 并将其包含在我的 MVC 项目中

我有家庭控制器的索引操作,并且我成功地使用了缓存

在我看来,我正在调用 2 Partial Views 。

查看 BlogPost 是动态的,所以我不希望它被缓存,但 RightSideBar 需要被缓存

那么如何设置不缓存 BlogPost DonutOutputCache 设置要缓存的总视图,包括两个部分视图

0 投票
1 回答
278 浏览

c# - 是什么导致 d:\ 驱动器在 Azure 上的 Web 应用程序中不可用?

一旦在一个蓝月亮,我们在初始化缓存时从我们的 Azure Web 应用程序中得到一个异常。

错误消息指出Failed to start monitoring changes to 'D:\home\site'。重新部署解决了这个问题。我们正在使用MvcDonutCaching,但我不知道这是否相关。

有没有人遇到过类似的问题,也许是我们如何解决这个问题的建议?

System.Web.HttpException (0x80070035):无法开始监视对“D:\home\site”的更改。在 System.Web.FileChangesMonitor.FindDirectoryMonitor(String dir, Boolean addIfNotFound, Boolean throwOnError) at System.Web.FileChangesMonitor.StartMonitoringPath(String alias, FileChangeEventHandler callback, FileAttributesData& fad) 在 System.Web.Caching.CacheDependency.Init(Boolean isPublic, String[] filenamesArg, String[] cachekeysArg, CacheDependency dependency, DateTime utcStart) at System.Web.Caching.CacheDependency..ctor(String filename, DateTime start) at System.Web.Hosting.MapPathBasedVirtualPathProvider.CacheLookupOrInsert(String virtualPath, Boolean isFile ) 在 System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) 在 System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) 在 System.Web.WebPages.DefaultDisplayMode.GetDisplayInfo(HttpContextBase httpContext, String virtualPath, Func 2 virtualPathExists) at System.Web.WebPages.DisplayModeProvider.GetDisplayInfoForVirtualPath(String virtualPath, HttpContextBase httpContext, Func2 virtualPathExists, IDisplayMode currentDisplayMode, Boolean requireConsistentDisplayMode) 在系统。 Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) at System.Web.Mvc.VirtualPathProviderViewEngine.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache) at System.Web.Mvc.ViewEngineCollection.<>c__DisplayClass6.<FindView>b__5(IViewEngine e) at System.Web.Mvc.ViewEngineCollection.Find(Func2 在 System.Web.Mvc.ViewResult.FindView(ControllerContext context) 在 System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName) 在 System.Web.Mvc.ViewResultBase.FindView(ControllerContext context) 的查找,布尔 trackSearchedPaths) System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) 在 System.Web.Mvc.Controller.b__1d 的 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) 的 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) 的(ControllerContext 上下文) System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid 的(IAsyncResult asyncResult,ExecuteCoreState innerState)1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) 在 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) 在 System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) 在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid `1.CallEndDelegate(IAsyncResult asyncResult) 在 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) 在 System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 在 System.Web.HttpApplication.ExecuteStep (IExecutionStep 步骤,Boolean& completedSynchronously)