如何在Google终端点框架中指定缓存控制

huangapple go评论68阅读模式
英文:

How to specify cache control in Google Endpoints Framework

问题

我尝试控制我的端点方法(建立在Google标准AppEngine上)的响应缓存标头。

我在框架中找到了这两个注释ApiCacheControl和ApiMethodCacheControl,但它们似乎不起作用;无论我如何配置这些注释,我的方法响应始终带有"Cache-Control=no-cache"标头。

您是否有如何使用这些注释的示例?

如果这些注释确实无法正常工作/不受支持,是否有其他方法可以控制我的方法响应的缓存标头?

有关上述注释的参考链接在这里:
https://cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiCacheControl

英文:

I try to control the cache headers of the response of my endpoint method (built on Google Standard AppEngine).

I found this two annotation ApiCacheControl and ApiMethodCacheControl in the framework, but they seem not working; my method response always come back with "Cache-Control=no-cache" header no matter how I configure those annotations.

Do you have an example how to use those?

If those are truly not working/supported, is there any other way that I can do to control my method response's cache header?

Reference to the above annotation can be found here:
https://cloud.google.com/endpoints/docs/frameworks/java/javadoc/com/google/api/server/spi/config/ApiCacheControl

答案1

得分: 1

关于 ApiMethodCacheControl,如文档中所述,已被弃用,您不应再使用它。

>已弃用。
>ApiMethodCacheControl 已被弃用,将在未来的 Cloud Endpoints 版本中移除。

另一方面,关于 ApiCacheControl,如Cloud Endpoints 框架注释和语法中所述:

>注意:Javadoc 列出了一些当前未实现的注释。这些注释包括:ApiCacheControl 和 ApiFrontendLimits。

我在公共问题跟踪器中找到了这个功能请求。我建议您将其加入到“星标”中,以确保您收到有关此问题的更新。您还可以通过点击右上角的齿轮图标并选择设置来调整通知设置。

我还找到了这个类似的问题,但没有答案。

最后,在这个问题中,我找到了一个答案:

>可扩展服务代理(ESP)不执行请求缓存。它的功能是拦截传入请求,验证身份验证令牌,然后将请求转发到 Google 服务控制,在那里将应用其他 API 管理规则,这些规则在您的 Open API 规范中定义。为了获得更好的性能,Endpoints 使用了分布式代理模型,以避免传统的多租户 API 代理通常会产生的额外网络跳转。实际上,这是 Google 内部用于为我们自己的 API 提供动力的相同模型。

英文:

About 'ApiMethodCacheControl', as mentioned in the docs, is deprecated and you should not use it anymore.

>Deprecated.
>ApiMethodCacheControl is deprecated and will be removed in a future version of Cloud Endpoints.

On the other hand, for ApiCacheControl, as mentioned in Cloud Endpoints Frameworks annotations and syntax:

>Note: The Javadoc lists some annotations that are currently not implemented. These annotations are: ApiCacheControl, and ApiFrontendLimits.

I found this Feature Request in the Public Issue Tracker.I would recommend you to "star" it to ensure that you receive updates about it. You can also adjust notification settings by clicking the gear icon in the top right corner and selecting settings.

I also found this other similar question without answer.

Finally in this question I did find an answer:

>The Extensible Service Proxy (ESP) does not perform request caching. Its function is to intercept incoming requests, validate auth tokens, and then forward the request to Google Service Control where additional API Management rules are applied as defined in your Open API spec. Endpoints uses a distributed proxy model for better performance, to avoid the extra network hop that's typically incurred with a traditional multi-tenant API proxy. This is in fact the same model used internally within Google to power our own APIs.

huangapple
  • 本文由 发表于 2020年10月23日 01:39:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/64487693.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定