outputcache

Manual outputcache refresh

一曲冷凌霜 提交于 2021-02-11 00:32:21
问题 Right now I have OutCache on an action with duration set to 365 days. However depending on some events I would like to clear the cache and there are multiple conditions for clearing cache. Moreover, VaryByParam is not an option. How can I achieve this? I think I can do something like this, store a variable in cookie like: RefreshCache = false and check this in VaryByCustom override method. Incase the RefreshCache evaluates to true, reset it to false, increment VaryByCustom argument variable

Manual outputcache refresh

℡╲_俬逩灬. 提交于 2021-02-11 00:31:11
问题 Right now I have OutCache on an action with duration set to 365 days. However depending on some events I would like to clear the cache and there are multiple conditions for clearing cache. Moreover, VaryByParam is not an option. How can I achieve this? I think I can do something like this, store a variable in cookie like: RefreshCache = false and check this in VaryByCustom override method. Incase the RefreshCache evaluates to true, reset it to false, increment VaryByCustom argument variable

Refresh OutputCache Profile on Demand

天涯浪子 提交于 2021-01-29 15:20:30
问题 I am using an OutputCache Profile to cache on the server some json data. [HttpGet] [OutputCache(CacheProfile = "1HourCacheProfile")] public JsonResult GetBranches() { var result = mMapper.Map<List<IntItem>>(mConfigurationServices.GetBranches()); return Json(new { list = result }, JsonRequestBehavior.AllowGet); } The profile is registered in Web.config as below I want to hook somehow a refresh logic on this cached output on different actions that are updating my source. I have found some

OutputCache with VaryByCustom not working

跟風遠走 提交于 2021-01-27 06:09:29
问题 I'm trying to implement caching in ASP.NET MVC 4 using the OutputCache attribute. Here is my controller action: [HttpGet] [OutputCache(Duration = CACHE_DURATION, VaryByCustom = "$LanguageCode;myParam", Location = OutputCacheLocation.Server)] public JsonResult MyAction(string myParam) { // this is called also if should be cached! } And here is the GetVaryByCustomString in the Global.asax: public override string GetVaryByCustomString(HttpContext context, string arg) { var pars = arg.Split(';');

OutputCache with VaryByCustom not working

微笑、不失礼 提交于 2021-01-27 06:04:52
问题 I'm trying to implement caching in ASP.NET MVC 4 using the OutputCache attribute. Here is my controller action: [HttpGet] [OutputCache(Duration = CACHE_DURATION, VaryByCustom = "$LanguageCode;myParam", Location = OutputCacheLocation.Server)] public JsonResult MyAction(string myParam) { // this is called also if should be cached! } And here is the GetVaryByCustomString in the Global.asax: public override string GetVaryByCustomString(HttpContext context, string arg) { var pars = arg.Split(';');

Invalidate the whole output cache in asp .net MVC 2

試著忘記壹切 提交于 2020-01-23 17:39:28
问题 How is it possible to invalidate the whole output cache in asp .net mvc 2? 回答1: AFAIK this is not possible. You can only invalidate specific actions that might have been cached by decorating them with the [OutputCache] attribute. HttpResponse.RemoveOutputCacheItem(Url.Action("Index", "Products")); 回答2: While I don't know if there is a way to do it in code, still recycling the worker process might invalidate the server cache. If this is true then you might even do it in code by having code to

Using outputcache in MVC

☆樱花仙子☆ 提交于 2020-01-16 03:28:08
问题 I have an action declared as following [Route("{language}/Navigation/Test")] [OutputCache(Duration = 3600, VaryByParam = "none")] public ActionResult Test() { return View(); } In order to check outputcache setting I added @DateTime.Now.Ticks.ToString() in view Test.cstml What troubles me is that when i run http://localhost/EN/Navigation/Test first time, view gets cached and page refresh returns a same number of ticks. Now if i change language and set http://localhost/DE/Navigation/Test number

How to set different Cache expire times for Client and Server caches

强颜欢笑 提交于 2020-01-12 04:28:30
问题 I would like to have certain pages have a 10 minute Cache for clients and 24 hours for the server. The reason is if the page changes, the client will fetch the updated version within 10 minutes, but if nothing changes the server will only have to rebuild the page once a day. The problem is that Output Cache settings seem to override the Client settings. Here is what I have setup: Custom ActionFilterAttribute Class public class ClientCacheAttribute : ActionFilterAttribute { private bool

How to Clear OutputCache for Website without Restarting App

白昼怎懂夜的黑 提交于 2020-01-10 18:53:10
问题 Is there a way clear or reset the outputcache for an entire website without a restart? I'm just starting to use outputcache on a site and when I make a mistake in setting it up I need a page I can browse to that will reset it. 回答1: This should do the trick: Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim path As String path="/AbosoluteVirtualPath/OutputCached.aspx" HttpResponse.RemoveOutputCacheItem(path) End Sub 回答2: Add the following code to controller or

ASP.NET MVC - caching pages on client side

孤街醉人 提交于 2020-01-10 03:18:46
问题 I have code that is cached this way: [OutputCache(Duration="3600", Location=OutputCacheLocation.Client)] Now, I don't exactly know how this output cache works. Where exactly does it keep the copy of a page? And what are the differences between OutputCacheLocation.Client and OutputCacheLocation.Browser ? 回答1: Where exactly does it keep the copy of a page? The location of where the cache is stored is determined by Location property of the OutputCacheAttribute . In your case you set Location