views:

95

answers:

1

Is it possible to cache the response of a http handler on the server and on the client?

This doesn't seem to be doing the trick:

_context.Response.Cache.SetCacheability(HttpCacheability.Public); _context.Response.Cache.SetExpires(DateTime.Now.AddDays(7));

The _context is the HTTPContext passed as an argument to the ProcessRequest method on the IHttpHandler implementation.

Any ideas?

Update: The client does cache images that are loaded through the httphandler, but if another client does the same call, the server hasn't got it cached. So for each client that asks for the image, the server goes to the database (and filestream). If we use a aspx page instead of a httphandler together with a caching profile, then the images are cached both on the client and the server.

+1  A: 

Thanks for your answer in the comments.

Cache.SetCacheability is used to define whether a proxy or the client is allowed to cache, not on the server.

Have a look at IIS 7 where it is explained how to cache the output of an HTTP handler at the server.

Timores
Thx, Timores, we'll check that! Strange that with an aspx page you can cache on server level, but with a httplevel you need to do it in IIS (or will iis save the changes in the web.config?)
Lieven Cardoen