【问题标题】:How To Achieve "Cache-Control: public, max-age=600" using AspNetCacheProfile in WCF如何在 WCF 中使用 AspNetCacheProfile 实现“Cache-Control: public, max-age=600”
【发布时间】:2011-12-14 12:57:59
【问题描述】:

我正在将缓存应用到我们的企业 API。我正在尝试实现类型为“public, max-age=600”的 Cache-Control,以便与支持反向代理缓存的负载均衡器兼容。

但是,我只能让 WCF 输出“private, max-age=600”,这不适合反向代理缓存。

我将以下配置文件设置为位置:服务器(因为我需要 ASP 应用程序级缓存),但我也尝试了所有其他位置,但没有一个会给我公开。

<caching>
  <outputCache enableOutputCache="true"/>
  <outputCacheSettings>
    <outputCacheProfiles>
      <add name="CacheDefault" duration="600" varyByParam="none" location="Any" />
    </outputCacheProfiles>
  </outputCacheSettings>
</caching>

我正在使用这样的标准 WCF,没什么特别的:

    [AspNetCacheProfile("CacheDefault")]
    [OperationContract]
    [WebGet(UriTemplate = "/GetData/{value}")]
    string GetData(string value);

我什至启动了一个全新的 WCF 服务项目,只是为了删除我当前生产代码中可能存在的任何混淆变量,但它仍然输出私有。

P.S. 我应该明确表示我不想手动覆盖 WebOperationContext.current.outgoingresponse.headers。我正在通过配置 AspNetCacheProfile 快速获胜。

任何帮助都会很棒!

非常感谢!

奥利弗

【问题讨论】:

    标签: wcf outputcache cache-control


    【解决方案1】:

    我遇到了不同的缓存技术。我在这里发布了一些我认为有用的内容 http://itswadesh.wordpress.com/2011/05/05/caching-in-asp-net/

    【讨论】:

    • 抱歉,这不适合这种情况。非常感谢,奥利弗
    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2020-08-11
    • 2015-04-08
    相关资源
    最近更新 更多