OutPut Cache is the caching technique to cache the static pages in ASP.NET.
Questions tagged [outputcache]
680 questions
7
votes
2 answers
OutputCache attribute not working on .NET 7 API endpoint
I have an API REST .NET 7 and the attribute [OutputCache] is not caching even in a endpoint without authorization
I added this:
services.AddOutputCache(options =>
{
options.AddBasePolicy(builder => builder.Cache()); //removing this line…

Ezequiel Irigoyen
- 105
- 2
- 6
7
votes
1 answer
Outputcache and 410 status response not working
I would like to throw a 410 status code for a page that does some database lookups. However it seems that outputcache only caches 200 status code pages. Is there anyway around this? I want to cache 410 pages for a while so the database doesn't get…

Mike Flynn
- 22,342
- 54
- 182
- 341
7
votes
3 answers
How best to work with the Expires header in ASP.NET MVC?
I want to be able to set a long expires time for certain items that a user downloads via GET request.
I want to say 'this is good for 10 minutes' (i.e. I want to set an Expires header for +10 minutes). The requests are fragments of HTML that are…

Simon_Weaver
- 140,023
- 84
- 646
- 689
7
votes
3 answers
ASP.Net MVC 3.0 Attribute [OutputCache] - Is this global, or by session?
When creating an ASP.Net MVC 3.0 application, I can include an OutputCache attribute on an action, and define the duration the cache will persist. After this duration, any activity causing the action to fire will cause this cached result to be…

barrypicker
- 9,740
- 11
- 65
- 79
7
votes
2 answers
mvc3 OutputCache RemoveOutputCacheItem RenderAction
I did my research but haven't found any answers.
I'm using Html.RenderAction in a masterpage ( to render page header with links specific to user permissions ). Action is decorated with OutputCache, returns partial control and gets cached as…

mb666
- 443
- 7
- 16
7
votes
4 answers
OutputCache in Razor view engine .cshtml page
Using ASP.NET MVC web forms we can put output cache either in controller level or view level. How can we mention "outputcache" in .cshtml page?
I did not find it anywhere. Where can I get the syntax?

ram
- 71
- 1
- 1
- 2
7
votes
2 answers
Caching of ASP.NET MVC Web API results
public class ValuesController : ApiController
{
[System.Web.Mvc.OutputCache(Duration = 3600)]
public int Get(int id)
{
return new Random().Next();
}
}
Since caching is set for 1 hour, I would expect the web server keeps returning…

user256890
- 3,396
- 5
- 28
- 45
7
votes
2 answers
Output caching in HTTP Handler and SetValidUntilExpires
I'm using output caching in my custom HTTP handler in the following way:
public void ProcessRequest(HttpContext context)
{
TimeSpan freshness = new TimeSpan(0, 0, 0, 60);
…

mayor
- 631
- 4
- 13
7
votes
2 answers
In ASP.NET, is it possible to output cache by host name? ie varybyhost or varbyhostheader?
I've got a website that has a number of host headers. The theme and data depend on the host header, and different hosts load different looking sites.
So let's imagine I have a website called "Foo" that returns search results. The same code runs both…

Pure.Krome
- 84,693
- 113
- 396
- 647
7
votes
1 answer
Set Page Output Cache VaryByCustom value programmatically
I want to use an Enum value for the types of VaryByCustom parameters I will support, is it possible to do this?
I tried setting it in the page itself
<%@ OutputCache Duration="600" VaryByParam="none"
…

Chris Marisic
- 32,487
- 24
- 164
- 258
7
votes
2 answers
Invalidate Output Cache if there is an exception on the page
I have output caching enabled in one of the pages as follows:
<%@ OutputCache Duration="300" VaryByParam="*"%>
The issue is that sometimes there is an exception and we display an appropriate message. But this page is then Cached and other users are…

shashi
- 4,616
- 9
- 50
- 77
7
votes
2 answers
ASP.NET MVC hits outputcache for every action
We are running quite a large site build with ASP.NET MVC 3 and AppFabric as a distributed caching solution. We have implemented a custom OutputCacheAdapter to use our AppFabric cluster.
We are seeing that ASP.NET calls the OutputCacheProvider.Get()…

TheNameless
- 363
- 3
- 8
6
votes
2 answers
outputcache mvc3 only logged out user caching
Is there a way to use the OutputCache attribute to cache the results of only logged out users and reevaluate for logged in users example:
What I'd Like
[OutputCache(onlycacheanon = true)]
public ActionResult GetPhoto(id){
var photo =…

maxfridbe
- 5,872
- 10
- 58
- 80
6
votes
2 answers
OutputCache.VaryByHeader is not generating a Vary header in the response
I have this action method:
[OutputCache(Duration = 2,
Location = OutputCacheLocation.Any,
VaryByHeader = "Accept-Charset")]
public ActionResult Index()
{
return View();
}
And the generated…

vtortola
- 34,709
- 29
- 161
- 263
6
votes
3 answers
ASPX That Returns An Image - Output Cache-able?
Greetings!
I've created an APSX web form that returns a remote image based on some supplied parameters. It can be used like this:
ImageGetter.aspx's markup and code look similar to this:
<%@…

Bullines
- 5,626
- 6
- 53
- 93