Reputation: 31
I have an endpoint for a WCF web service which is not getting output cache hits in the performance monitor for AJAX requests, it does get an output cache for non AJAX requests to endpoint.
Web config:
<caching>
<outputCacheSettings >
<outputCacheProfiles>
<add location="Any" name="myCache" duration="3600" varyByParam="*" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
Is there an option I'm missing in the config? I've not included Javascript because I doubt the problem lies there since the server shouldn't have to check any headers to determine cache worthiness.
The endpoint:
[AspNetCacheProfileAttribute("myCache")]
[WebGet(ResponseFormat= WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "suburb?name={name}&state={state}&category={category}&bedrooms={bedrooms}&country={country}")]
Upvotes: 3
Views: 868
Reputation: 6518
When you make an ajax call , it is possible that, you are passing it as cache: false.
When you call like that, ajax call will pass the URL with an extra parameter and value will be a random unique number. Since asp.net method receive this extra parameter and you configure outputcache with varyByParam="*" , this method will never cache. The solutions are
Sorry for the late reply. I saw this question just now.
Upvotes: 1