outputcache

Is there any way to clear cache from server farm?

时光毁灭记忆、已成空白 提交于 2019-12-12 05:34:16
问题 I have implemented OutputCache in an application and it works fine, but since I have specified the location as server, and the applications runs in server farm (2 servers) , when I clear the cache, it clears only from one server at one time. I have thought about specifying a server location (hardcode), so that the cache will be stored at one place and can be easily cleared when I have to. So, is there any way to hardcode server name for the location attribute in OutputCache? Or from webconfig

HttpCachePolicy SetETag

六月ゝ 毕业季﹏ 提交于 2019-12-12 04:58:51
问题 http://msdn.microsoft.com/en-us/library/system.web.httpcachepolicy.setetag.aspx Is there a way to check for is the ETag is already set? I Keep getting the exception The ETag header has already been set But i can figure out how to check for it 回答1: You can check the response headers for it. For example in a ActionResult public override void ExecuteResult(ControllerContext context) { if (_etag != null && context.HttpContext.Response.Headers["ETag"] == null) { context.HttpContext.Response

Persist page outputcache

落爺英雄遲暮 提交于 2019-12-12 04:31:28
问题 Is there an option to make page outputcache persist even after IIS restart or web.config modification? Right now when I upload files the site recompiles and the outputcache resets and get cached upon the next page request. 回答1: You can implement your own outputcache provider by implementing the OutputCacheProvider: public abstract class OutputCacheProvider : ProviderBase { public abstract object Get(string key); public abstract object Add(string key, object entry, DateTime utcExpiry); public

exception on use of Html.Action when controller is decorated with outputcache attribure

本小妞迷上赌 提交于 2019-12-11 18:03:46
问题 An exception is thrown when I call Html.Action from a view when the controller is decorated with the OutputCache attribute. But when I remove the attribute from the controller everything works as expected. I do not want to remove the OutputCache-attribute and I don't understand how the attribute is responsible for throwing the exception. How do I solve this problem? Controller: [OutputCache(Location = OutputCacheLocation.None, NoStore = true)] public class TestController : Controller { public

Caching a dynamically/programmatically added user control

时光毁灭记忆、已成空白 提交于 2019-12-11 06:28:07
问题 I'm trying to learn about caching, and in particular, partial caching using controls. My website is running slow on certain pages, so caching as much as possible will be helpful. Having run a number of experiments from code I have found on SO and various other Google results, I am running into an issue with dynamically added controls. I have set up a simple page, containing this code: <%@ Page Language="VB" Debug="true" %> <%@ Register TagPrefix="controls" TagName="control" Src="~/test

subclassing outputcache issues in mvc3

醉酒当歌 提交于 2019-12-11 06:18:42
问题 I am having some issues understanding what is happening when I create a simple subclass of OutputCacheAttribute in MVC3. Here is the code: public class ExampleOutputCacheAttribute : OutputCacheAttribute { public ExampleOutputCacheAttribute() { // breakpoint here } public override void OnActionExecuting(ActionExecutingContext filterContext) { // breakpoint here base.OnActionExecuting(filterContext); } public override void OnActionExecuted(ActionExecutedContext filterContext) { // breakpoint

session becoming null in MVC AuthorizeAttribute

不问归期 提交于 2019-12-11 03:34:30
问题 I am using an AuthorizeAttribute to check that users have an over 18 age cookie set to access pages. This works fine, but I am extending in slightly now. As all Views use this Attribute, I am using it to allow me to launch my site early. If uses add ?VIEWSITE=true to any URL, it will set a Session variable, and allow them access to the site. Otherwise, they get directed to a holding page. This works fine first time the page runs. But, I am using output caching on the page, and the next time

Output cache in MVC

你。 提交于 2019-12-11 03:08:46
问题 How can I get the dropbox items in cache, in MVC? I have tried the following, but it calls the page function each time. What could be the issue or the right way to do it? Please suggest. [OutputCache(Duration = 10, Location = System.Web.UI.OutputCacheLocation.Server, NoStore = true, Order = 0)] public IEnumerable<SelectListItem> GetRegions() { 回答1: You should have it in your controller on those actions there 来源: https://stackoverflow.com/questions/9784914/output-cache-in-mvc

ASP.NET MVC Caching vary by controller action parameter

隐身守侯 提交于 2019-12-11 03:05:56
问题 Is there any way I can vary caching by a controller action parameter using the outputcache attribute? We have varybyparam which will not work if my parameters are embedded within the URL in a REST manner. 回答1: Caching works this way by default. Different URLs give different cache locations. Perhaps there is something missing from your question, but, as stated, it already works this way. 回答2: Its also important to realize in a Action method that 'VaryByParam' does not mean 'Vary by the

WebAPI OutputCache cache invalidation

泪湿孤枕 提交于 2019-12-10 20:14:29
问题 I have the following caching attribute on my controller method: [CacheOutput(ClientTimeSpan = 14400, ServerTimeSpan = 14400)] I am attempting to clear the cache. However, after running this line of code: //clear cache cache.RemoveStartsWith(Configuration.CacheOutputConfiguration().MakeBaseCachekey("BeamsController", "Get")); I am still getting a 304 not-modified response without the controller method being invoked. I am using this library https://github.com/filipw/AspNetWebApi-OutputCache 回答1