IIS Caching

Topics: Web Api
Nov 18, 2011 at 9:59 AM

Hi

Sorry if this is a bit off the topic, just didn't know where else to ask the question....

I've created a small WCF WEBAPI service and a small Silverlight test client, using the Client HTTP stack...

The first time I request the service I get the following response header:

HTTP/1.1 202 Accepted

Cache-Control: public, max-age=86400

Content-Length: 3

Content-Type: text/plain

Expires: 86400

Location: http://myservice?fileid=ee5956c8-c605-4f09-9dac-9d1265be4adf

Server: Microsoft-IIS/7.5

X-AspNet-Version: 4.0.30319

X-Powered-By: ASP.NET

Date: Fri, 18 Nov 2011 10:49:04 GMT

so I would kind of expect, that the next time (within 86400 sec.) I request the service, I would get a cached result, and not hit my service again, however I hit the myservice, each time I request the service.....

If I change my client to use the Browser HTTP stack, I only hit my service the first time....

To me it looks like IIS is not caching the result.... shouldn't it? and is there a way to set it up to cache the result?

TIA

Søren

 

 

Nov 18, 2011 at 8:02 PM

When you use "Cache-Control: public, max-age=86400" you are not telling the server to cache the response. You are telling any intermediary that may move the request along the request/response chain that they can cache it for that amount of time. When you use the Browser HTTP stack, the Browser caches the response. When you changed to the ClientHttp stack you didn't have any caching ability. You will have to implement client side caching yourself or make sure that some intermediary caches the response. 

I don't know if there is OOTB caching at the Service layer like MVC has, but you could easily implement caching yourself. 

This post indicated there isn't anything

Hope that helps

Nov 21, 2011 at 9:42 AM

Ok, so basically I'll have to do the caching myself, either in my service layer or in the client, right?

Søren