Injecting data caching and other effects into the WCF pipeline -
i have service returns same results given parameter. naturally cache results on client.
is there way introduce caching , other effect inside wcf pipeline? perhaps custom binding class site between client , actual http binding.
edit:
just clear, i'm not talking http caching. endpoint may not http , looking @ far more effects caching. example, 1 effect need prevent multiple calls same parameters.
the wcf service can use cache-control directives in http header client how should use client side cache. there many options, the part of http protocol. can example define how long client can data local cache instead of making requests server. clients implemented http, web browsers, follow instructions. if client use ajax
requests wcf server, corresponding ajax
call return data local cache.
moreover 1 can implement many interesting caching scenarios. example if 1 set "cache-control" "max-age=0" (see here example), client make revalidation of cache server. typically server send named "etag" in header data. "etag" represent md5 hash or other free information changed if data changed. client send automatically "etag", received server, inside header of request server. server can answer special response http/1.1 304 not modified
(instead of typical http/1.1 200 ok
response) , with body having no data. in case client safe data local cache.
i use "cache-control:max-age=0" additionally cache-control: private
switch off caching data on proxy , declare data cached, not shared users.
if want read more caching control respect of http headers i'll recommend read following caching tutorial.
updated: if want implement general purpouse caching can use microsoft enterprise library contains caching application block. microsoft enterprise library published on codeplex the source code. alternative in .net 4.0 can use system.runtime.caching. can used not in asp.net (see here)
i continue recommend use http binding http caching if possible in environment. in way save many time of development , receive @ end more simple, scalable , effective application. because http important, 1 implemened useful things can use out-of-the-box. caching oly 1 features.
Comments
Post a Comment