i'm trying to use OutputCaching in my ASP.NET MVC website. Problem is, when i try and change the value of one my querystring params, it's returning the data for the first item that was requested!
Here's my code (with the param names changed) ...
[ApiAuthorize]
[HandleErrorAsJson]
public class SearchController : Controller
{
[AcceptVerbs(HttpVerbs.Get)]
[OutputCache(Duration = 60, VaryByParam = "*")]
public ActionResult ScoreCard(string foo, byte? bar, byte? pewpew)
{
..
}
}
and here's two sample calls i'm making to this action :-
so the data from the first call (foo = hello world, Pew Pew) is returned as a 200 OK. Then the second api call returns a 200 OK but with the data from the previous call.
Also, i'm not using any proxy server. If i comment out the OutputCache attribute, all is good.
I've also tried the following (manually listing each time i need to cache) .....
[OutputCache(Duration = 60, VaryByParam = "foo,key,bar,pewpew")]
No luck :(
Notice how i need to make sure that i include the API 'Key' parameter as part of the cache unique key. I don't want to people to search for the same thing, but if the second person doesn't have the right key, they shouldn't get a cached result, but an error message (techinically, it's a 401 Not Authorised, but anyways)...
Thoughts?
The list of parameters in VaryByParam is supposed to be semicolon delimited, not comma delimited. Give that a try. That said, the * should have worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With