

response code: 200 // List of backend response codes that can be cached. It is recommended that normal response codes (such as 200) be entered to prevent abnormal response content from being cached.request method: GET // Request methods that can be cached.content type: application/json; charset=utf-8 // Backend response Content-Type that can be cached. Note that the value should fully match the response header. For example, "application/json" and "application/json; charset=utf-8" do not match.cache ttl: 60 // Caching duration, in seconds.

vary query params: name, department // List of query parameter names used as the cache keys, which is empty by default.vary headers: x-cache-header // Used to cache the list of header parameter names for the key, which is empty by default.

GET /cache/it, the cache does not exist, the request is sent to the backend service, and the response header X-Cache-Status is set to Miss.HTTP/1.1 200 OKContent-Type: application/json; charset=utf-8Content-Length: 335X-Cache-Key: 6fb1b6a4440980c758b0eff31177a41dX-Cache-Status: MissDate: Tue, 26 Apr 2022 16:04:19 GMTX-Kong-Upstream-Latency: 948X-Kong-Proxy-Latency: 321Via: kong/2.4.1
GET /cache/it is sent again within the cache time to live (TTL), the cache hits, and the response header X-Cache-Status is set to Hit.HTTP/1.1 200 OKServer: openrestyContent-Type: application/json; charset=utf-8X-Cache-Key: 6fb1b6a4440980c758b0eff31177a41dAge: 2X-Cache-Status: HitDate: Tue, 26 Apr 2022 16:09:23 GMTVary: Accept-EncodingContent-Length: 335X-Kong-Upstream-Latency: 0X-Kong-Proxy-Latency: 0Via: kong/2.4.1
name parameter is included in vary query params:GET /cache/it?name=john, the cache does not exist, the request is sent to the backend, and the response header X-Cache-Status is set to Miss.GET /cache/it?name=john is sent again within the cache TTL, the cache hits, and the response header X-Cache-Status is set to Hit.GET /cache/it?name=tom is sent within the cache TTL, the response header X-Cache-Status is set to Miss because the name parameter differs.GET /proxy-cache/:cache_key to query the cached content of a specified cache key.X-Cache-Key of the API request.404 is returned.200 is returned, and the response body is as follows:{"ttl": 60,"req_body": "","headers": {"Date": "Wed, 27 Apr 2022 03:09:39 GMT","X-Cache-Status": "Miss","ETag": "W/\\"14f-3sRRcm7jenKggj3qhgagNHIwiqw\\"","Vary": "Accept-Encoding","connection": "keep-alive","set-cookie": "sails.sid=s%3AT_YQH4rJgm2TYpJ5o6Ql1nH-vlA6pR19.JR3bgC6WfzWO1OqDPwzaNn%2FXX6PcGdg2vTaT6d1BbfQ; Path=/; HttpOnly","content-length": "335","content-type": "application/json; charset=utf-8","X-Cache-Key": "6fb1b6a4440980c758b0eff31177a41d"},"body": "<cached response body>","status": 200,"timestamp": 1651028979,"version": 1,"body_len": 335}
Cache-Control request header, enable the cache-control configuration item in the plugin.X-Cache-Status response header description:Miss: The request matches the cache policy but does not hit the cache.Hit: The request hits the cache.Bypass: The request does not meet the matching condition set by the cache plugin.Refresh: The cache does not expire. However, the request bypasses the cache due to Cache-Control in the request header.Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan