asp.net - 从移动应用程序调用时,WCF 缓存不起作用
问题描述
我已经使用以下代码实现了 WCF 缓存:
iService.vb
<OperationContract()>
<AspNetCacheProfile("CacheFor60Seconds")>
<WebGet(RequestFormat:=WebMessageFormat.Json, UriTemplate:="some-url?id={id}", BodyStyle:=WebMessageBodyStyle.Bare, ResponseFormat:=WebMessageFormat.Json)>
网络配置
<system.web>
<caching>
<outputCache enableOutputCache="true"></outputCache>
<outputCacheSettings>
<outputCacheProfiles>
<add name="CacheFor60Seconds" duration="60" varyByParam="id"/>
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0" multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>
当我使用浏览器调用 REST API 时,该解决方案可以正常工作。响应被缓存。但是,当我从移动应用程序调用 REST API 时,响应不会被缓存。我在这里错过了什么吗?
解决方案
事实证明,出于某种原因,我不得不在 Web.config 中包含另一个参数,该参数在移动应用程序中使用/调用/调用:
<add name="CacheFor60Seconds" duration="60" varyByParam="id;param2"/>
推荐阅读
- c# - 从另一个事件调用一个事件
- c# - 使用 Kestrel 在 .NET Core 控制台应用程序中返回 HTML 视图
- java - 如何在 morphia 中编写查询?
- java - 我的代码中缺少什么?JAVA
- smtplib - 没有使用 smtplib localhost 发送电子邮件
- php - 如何在购物车页面(woocommerce)上更改自定义费用顺序(升序/降序)
- python - 尝试使用 python 对 xml 文件名使用西班牙语字符(或忽略它们)
- speech-recognition - INVALID_ARGUMENT:请求有效负载大小超过限制:10485760 字节
- ios - 在 iOS 的表格中显示响应式图像和标签
- spring-integration - 自定义入站通道适配器以调用 Pojo 服务