目录地址 /usr/local/share/lua/5.1/kong/plugins/proxy-cache
缓存
curl -i -X POST http://localhost:8001/plugins \
--data name=proxy-cache \
--data config.content_type="application/json" \
--data config.cache_ttl=30 \
--data config.strategy=memory
HTTP/1.1 201 Created
Date: Fri, 31 Jul 2020 08:35:55 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/2.1.0
Content-Length: 481
X-Kong-Admin-Latency: 7
{"created_at":1596184555,"id":"12ac84de-7006-46f7-99b9-94a0dec1b706","tags":null,"enabled":true,"protocols":["grpc","grpcs","http","https"],"name":"proxy-cache","consumer":null,"service":null,"route":null,"config":{"request_method":["GET","HEAD"],"cache_control":false,"vary_query_params":null,"storage_ttl":null,"response_code":[200,301,404],"cache_ttl":30,"vary_headers":null,"strategy":"memory","content_type":["application\/json"],"memory":{"dictionary_name":"kong_db_cache"}}
查看缓存
curl -i -X GET http://localhost:8000/mock/request
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Content-Length: 891
Connection: keep-alive
X-Cache-Key: ea984309dd577124e1f65cde1065f6ac
X-Cache-Status: Bypass
Server: Cowboy
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Access-Control-Allow-Headers: host,connection,x-forwarded-for,x-forwarded-proto,x-forwarded-host,x-forwarded-port,x-real-ip,x-forwarded-prefix,user-agent,accept,x-request-id,via,connect-time,x-request-start,total-route-time
Access-Control-Allow-Credentials: true
X-Powered-By: mockbin
Vary: Accept, Accept-Encoding
Etag: W/"37b-sAIQN2uDDnfjTSxhJVhSJAtiNTU"
Date: Fri, 31 Jul 2020 08:37:07 GMT
Via: kong/2.1.0
X-Kong-Upstream-Status: 200
X-Kong-Upstream-Latency: 1256
X-Kong-Proxy-Latency: 525
Kong-Cloud-Request-ID: 96f8bc4accd38f58265fecccba92eac6
X-RateLimit-Remaining-Minute: 4
X-RateLimit-Limit-Minute: 5
RateLimit-Remaining: 4
RateLimit-Limit: 5
RateLimit-Reset: 55
删除缓存
curl -i -X DELETE http://localhost:8001/proxy-cache
HTTP/1.1 204 No Content
Date: Fri, 31 Jul 2020 08:38:58 GMT
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/2.1.0
X-Kong-Admin-Latency: 4