This is not working for some reason:
[OutputCache(Duration = 600, VaryByParam = "id")]
public string GetSomeValue(int id)
{
return _service.GetSomeValue(id).ToString();
}
I tested this in a controller that returns a View and it does work.
Any idea why? or any possible workaround?
The attribute must be placed onto the Action itself not this method
Based on your comment it sounds like you are looking for server caching. I’d recommend something like memcached or Redis but equally you can use the cache built into IIS. Note you must be aware of when your cache should be burst and of how you would deal with distribution if you are on a web farm. In it’s simplest form you could try this
The full options of Add give you the chance to set a sliding or absolute expiration
Pass in null for dependencies for example but set expiration as you wish.