Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: proxy-cache not support restful api #7096

Closed
galaxy-sea opened this issue May 21, 2022 · 6 comments · Fixed by #7111
Closed

bug: proxy-cache not support restful api #7096

galaxy-sea opened this issue May 21, 2022 · 6 comments · Fixed by #7111
Assignees
Labels
bug Something isn't working

Comments

@galaxy-sea
Copy link

Current Behavior

        "proxy-cache": {
            "cache_key":  ["$uri", "-cache-id"],
            "cache_bypass": ["$arg_bypass"],
            "cache_method": ["GET"],
            "cache_http_status": [200],
            "hide_cache_headers": true,
            "no_cache": ["$arg_test"]
        }

Test Plugin:

$ curl http://127.0.0.1:9080/hello -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 6
Connection: keep-alive
Server: APISIX web server
Date: Tue, 03 Mar 2020 10:45:36 GMT
Last-Modified: Tue, 03 Mar 2020 10:36:38 GMT
Apisix-Cache-Status: MISS

hello
$ curl http://127.0.0.1:9080/hello -X POST -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 6
Connection: keep-alive
Server: APISIX web server
Date: Tue, 03 Mar 2020 11:14:46 GMT
Last-Modified: Thu, 20 Feb 2020 14:21:41 GMT
Apisix-Cache-Status: HIT

hello

Expected Behavior

        "proxy-cache": {
            "cache_key":  ["$uri", "-cache-id"],
            "cache_bypass": ["$arg_bypass"],
            "cache_method": ["GET"],
            "cache_http_status": [200],
            "hide_cache_headers": true,
            "no_cache": ["$arg_test"]
        }

Test Plugin:

$ curl http://127.0.0.1:9080/hello -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Length: 6
Connection: keep-alive
Server: APISIX web server
Date: Tue, 03 Mar 2020 10:45:36 GMT
Last-Modified: Tue, 03 Mar 2020 10:36:38 GMT
Apisix-Cache-Status: MISS

hello
$ curl http://127.0.0.1:9080/hello -X POST -i
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Connection: keep-alive
Server: APISIX web server
Date: Tue, 03 Mar 2020 11:14:46 GMT
Last-Modified: Thu, 20 Feb 2020 14:21:41 GMT

modify hello

Error Logs

No response

Steps to Reproduce

11

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@juzhiyuan juzhiyuan added the checking check first if this issue occurred label May 21, 2022
@tzssangglass
Copy link
Member

Hi @galaxy-sea I don't understand what you are trying to say.

  1. From your description, I don't see anything related to restful api;
  2. Can you describe the Expected Behavior in detail?

@tokers
Copy link
Contributor

tokers commented May 23, 2022

@galaxy-sea Do you mean that when you create a route with the proxy-cache plugin, the actual behaviors doesn't match the one specified in the plugin (the second POST request should not hit the cache) ?

@galaxy-sea
Copy link
Author

@galaxy-sea Do you mean that when you create a route with the proxy-cache plugin, the actual behaviors doesn't match the one specified in the plugin (the second POST request should not hit the cache) ?

yes , the second POST request should not hit the cache.
是的,POST 请求不应该命中缓存

@tokers
Copy link
Contributor

tokers commented May 23, 2022

@galaxy-sea What's your APISIX version? Would you try to use the latest APISIX and set the cache_strategy to memory to see the result?

The default cache strategy is disk and I'm afraid there is bug there about the cache method handling.

@galaxy-sea
Copy link
Author

galaxy-sea commented May 23, 2022

APISIX version is 2.10.1,

Apache APISIX does not implement the standard HTTP cache😭😭😭.
Apache APISIX没有实现标准的http缓存策略

@spacewander spacewander added bug Something isn't working and removed checking check first if this issue occurred labels May 23, 2022
@soulbird
Copy link
Contributor

The configuration of cache_method, under the disk policy, controls whether the response will be written to the cache. During the request process, if the cache_key matches, the data in the cache will be retrieved to respond to the client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants