A property on the page can be read but the timing is somehow wrong to create anything but the very first cache entry. I don't understand how Varybycustom would be very useful if you can't actually supply a custom string.
I can set a string by using Response. It seems to create unique cache entries the first couple of times but after a point all of the autopostback stuff seems to quit working. The second trip will give me 8 cache entries but the third try will always just return the second entry. The content you requested has been removed.
So you are broadcasting your private information to the entire world. Don't do it. It is very difficult to change the rules like Duration, VaryByParam, VaryByCustom, Location used with "OutputCache" on each controller method when your large application has already been deployed.
So, there is an alternative to configure the OutputCache profile in the web. By configuring output caching in the web configuration file, you can control it on one central location. You can create one cache profile and apply the profile to several controllers or controller actions. Also, you can modify the web configuration file without recompiling your application.
Any changes to the web configuration file will be detected automatically and applied to the entire application. In the following code you can see I have used a new attribute CacheProfile that maps to Cache10Seconds that is in web. This approach is pretty good because rather than targeting any specific outputCacheProfile we can disable all at once, awesome. View All. Output Caching in MVC. Abhimanyu K Vatsa Updated date Jun 27, Cached Content Locations. Please note, there is no guarantee that content will be cached for the amount of time that we specify.
When memory resources become low, the cache starts evicting content automatically. OutputCache label has a "Location" attribute and it is fully controllable. Its default value is "Any", however there are the following locations available; as of now, we can use any one. Any 2. Client 3. Register the handler in the Global. Generic; using System. ComponentModel; using System. Text; using System. Web; using System.
UI; using System. WebControls; using Microsoft. Publishing; using Microsoft. ApplicationRuntime; using Microsoft. The problem is that when I call the action with another parameter, not included in the VaryByCustom string, the controller action is called anyway, also if is should be cached and the GetVaryByCustomString returns the same result.
Then in your GetVaryByCustomString method, try to return your generated string instead of calling the base method:. As you can see, it doesn't do what you think it does, it only compares the Browser type with the string you provided and if there's no match it returns null , not the string you provided.
I suspect the [OutputCache] change alone will suffice, but try changing the method as well. I'm trying to implement caching in ASP.
0コメント