积极答复者
如何清除WCF service 的缓存

问题
-
请教各位师傅,WCF SVC service 是否会自动缓存?我在用AJAX调用、调试一个svc服务,发现该svc有错误,并修改之。重新启动IIS,再调用该服务,发现仍然提示之前的错误,且无法进入在服务中设的断点。我修改调用传入的参数为其他不同的值,则可以进入断点。之后如果调用的参数如果曾经被使用过,是无法进入调试断点的,必须更改为其他未曾使用过的参数。
以下是服务配置xml代码:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<endpointBehaviors>
<behavior name="JsonGraphServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="JsonGraphServiceAspNetAjaxBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="JsonGraphServiceAspNetAjaxBehavior"
name="JsonGraphService">
<endpoint address="" behaviorConfiguration="JsonGraphServiceAspNetAjaxBehavior"
binding="webHttpBinding" contract="JsonGraphService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>- 已移动 KeFang Chen 2010年3月30日 5:54 (发件人:ASP.NET 与 AJAX)
答案
-
WCF在Web编程模型里涉及到缓存的问题。
Rest的一大优点就是减少Http缓存的使用量,因而提升服务的性能。之前我们需要通过控制Http请求和应答消息头来实现对于缓存的控制。现在在WCF4.0中,提供了一种新的类型AspNetCacheProfile。来配置每个操作的http缓存。CachingParameterInspector。我在这个文章里介绍过。
但是WCF4.0之前的版本好像没有提供显示的控制设置。WCF4.0可以通过配置文件来简单搞定。
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheFor30Seconds" duration="30" varyByParam="format" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>然后在操作上应用这个属性,代码如下:
[AspNetCacheProfile("CacheFor30Seconds")]
[WebGet(UriTemplate = "/Rest4/Get/{id}")]
public string GetData(string id)
{
return "Hello Rest";
}
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum- 已标记为答案 Mog Liang 2010年4月6日 9:28
-
Thanks all the same, Frank.
I have resolved this problem by typing and running the command "iisreset".
- 已标记为答案 Frank Xu LeiModerator 2010年4月28日 11:03
全部回复
-
WCF在Web编程模型里涉及到缓存的问题。
Rest的一大优点就是减少Http缓存的使用量,因而提升服务的性能。之前我们需要通过控制Http请求和应答消息头来实现对于缓存的控制。现在在WCF4.0中,提供了一种新的类型AspNetCacheProfile。来配置每个操作的http缓存。CachingParameterInspector。我在这个文章里介绍过。
但是WCF4.0之前的版本好像没有提供显示的控制设置。WCF4.0可以通过配置文件来简单搞定。
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheFor30Seconds" duration="30" varyByParam="format" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>然后在操作上应用这个属性,代码如下:
[AspNetCacheProfile("CacheFor30Seconds")]
[WebGet(UriTemplate = "/Rest4/Get/{id}")]
public string GetData(string id)
{
return "Hello Rest";
}
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum- 已标记为答案 Mog Liang 2010年4月6日 9:28
-
Thanks all the same, Frank.
I have resolved this problem by typing and running the command "iisreset".
- 已标记为答案 Frank Xu LeiModerator 2010年4月28日 11:03
-
Thanks all the same, Frank.
I have resolved this problem by typing and running the command "iisreset".
Welcome~
Frank Xu Lei--谦卑若愚,好学若饥
专注于.NET平台下分布式应用系统开发和企业应用系统集成
Focus on Distributed Applications Development and EAI based on .NET
欢迎访问老徐的中文技术博客:Welcome to My Chinese Technical Blog
欢迎访问微软WCF中文技术论坛:Welcome to Microsoft Chinese WCF Forum
欢迎访问微软WCF英文技术论坛:Welcome to Microsoft English WCF Forum