Cache de saída para um ApiController (MVC4 Web API)
Estou tentando armazenar em cache a saída de umApiController método na API da Web.
Aqui está o código do controlador:
public class TestController : ApiController
{
[OutputCache(Duration = 10, VaryByParam = "none", Location = OutputCacheLocation.Any)]
public string Get()
{
return System.DateTime.Now.ToString();
}
}
N.B. Eu também tentei o atributo OutputCache no próprio controlador, bem como várias combinações de seus parâmetros.
A rota está registrada no Global.asax:
namespace WebApiTest
{
public class Global : HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute("default", routeTemplate: "{controller}");
}
}
}
Recebo uma resposta bem-sucedida, mas não está em cache em lugar algum:
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/xml; charset=utf-8
Expires: -1
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Wed, 18 Jul 2012 17:56:17 GMT
Content-Length: 96
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">18/07/2012 18:56:17</string>
Não consegui encontrar documentação para o cache de saída na API da Web.
Esta é uma limitação da API da Web no MVC4 ou estou fazendo algo errado?