AWS API Gateway缓存会忽略查询参数 [英] AWS API Gateway caching ignores query parameters

查看:220
本文介绍了AWS API Gateway缓存会忽略查询参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在AWS API Gateway端配置缓存,以提高REST API的性能.我正在尝试配置的端点正在使用查询参数.我已经在AWS API Gateway端启用了缓存,但是不幸的是不得不发现在构建缓存键时它会忽略查询参数.

I'm configuring the caching on AWS API Gateway side to improve performance of my REST API. The endpoint I'm trying to configure is using a query parameter. I already enabled caching on AWS API Gateway side but unfortunately had to find out that it's ignoring the query parameters when building the cache key.

例如,当我使用查询参数"test1"进行第一次GET调用时

For instance, when I make first GET call with query parameter "test1"

GET https://2kdslm234ds9.execute-api.us-east-1.amazonaws.com/api/test?search=test1

对此调用的响应保存在缓存中,然后在此之后我调用另一个查询参数"test2"

Response for this call is saved in cache, and when after that I make call another query parameter - "test2"

GET https://2kdslm234ds9.execute-api.us-east-1.amazonaws.com/api/test?search=test2

我再次收到第一个电话的答复.

I get again response for first call.

用于缓存的设置非常简单,我没有找到与参数配置有关的内容.

Settings for caching are pretty simple and I didn't find something related to parameters configuration.

如何配置网关缓存以考虑查询参数?

How can I configure Gateway caching to take into account query parameters?

推荐答案

您需要在Gateway API面板中配置此选项.

You need to configure this option in the Gateway API panel.

  • 选择您的API,然后单击资源".
  • 选择方法并查看 URL查询字符串会话.
  • 如果没有查询字符串,请添加一个.
  • 标记查询字符串的缓存"选项.
  • 执行最终测试,最后部署更改.
  • Choose your API and click Resources.
  • Choose the method and see the URL Query String session.
  • If there is no query string, add one.
  • Mark the "caching" option of the query string.
  • Perform the final tests and finally, deploy changes.

屏幕截图

这篇关于AWS API Gateway缓存会忽略查询参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆