@@ -18,7 +18,9 @@ You can configure how to handle unauthorized requests to invalidate a cache key
18
18
* ` IgnoreWithWarning ` - ignores the request to invalidate and adds a ` warning ` header in the response.
19
19
* ` Fail ` - fails the request to invalidate the cache key with a 403 response status code.
20
20
21
- ## Example
21
+ ## Examples
22
+
23
+ ### Minimal setup
22
24
23
25
``` yml
24
26
plugins :
@@ -28,24 +30,71 @@ custom:
28
30
# Enable or disable caching globally
29
31
apiGatewayCaching :
30
32
enabled : true
31
- clusterSize : ' 0.5' # defaults to '0.5'
32
- ttlInSeconds : 300 # defaults to the maximum allowed: 3600
33
- perKeyInvalidation :
34
- requireAuthorization : true # default is true
35
- handleUnauthorizedRequests : IgnoreWithWarning # default is "IgnoreWithWarning"
36
33
37
34
functions :
38
- # Responses are not cached
35
+ # Responses are cached
39
36
list-all-cats :
40
37
handler : rest_api/cats/get/handler.handle
41
- role : listCatsRole
42
38
events :
43
39
- http :
44
40
path : /cats
45
41
method : get
46
42
caching :
47
- enabled : false # default is false
43
+ enabled : true
44
+
45
+ # Responses are *not* cached
46
+ update-cat :
47
+ handler : rest_api/cat/post/handler.handle
48
+ events :
49
+ - http :
50
+ path : /cat
51
+ method : post
52
+
53
+ # Responses are cached based on the 'pawId' path parameter and the 'Accept-Language' header
54
+ get-cat-by-paw-id :
55
+ handler : rest_api/cat/get/handler.handle
56
+ events :
57
+ - http :
58
+ path : /cats/{pawId}
59
+ method : get
60
+ caching :
61
+ enabled : true
62
+ cacheKeyParameters :
63
+ - name : request.path.pawId
64
+ - name : request.header.Accept-Language
65
+ ` ` `
66
+
67
+ ### Configuring the cache cluster size and cache time to live
68
+ Cache time to live and invalidation settings are applied to all functions, unless specifically overridden.
69
+
70
+ ` ` ` yml
71
+ plugins :
72
+ - serverless-api-gateway-caching
48
73
74
+ custom :
75
+ # Enable or disable caching globally
76
+ apiGatewayCaching :
77
+ enabled : true
78
+ clusterSize : ' 0.5' # defaults to '0.5'
79
+ ttlInSeconds : 300 # defaults to the maximum allowed: 3600
80
+ perKeyInvalidation :
81
+ requireAuthorization : true # default is true
82
+ handleUnauthorizedRequests : Ignore # default is "IgnoreWithWarning"
83
+
84
+ ```
85
+
86
+ ### Configuring per-function cache time to live, cache invalidation strategy and cache key parameters
87
+
88
+ ``` yml
89
+ plugins :
90
+ - serverless-api-gateway-caching
91
+
92
+ custom :
93
+ # Enable or disable caching globally
94
+ apiGatewayCaching :
95
+ enabled : true
96
+
97
+ functions :
49
98
# Responses are cached based on the 'pawId' path parameter and the 'Accept-Language' header
50
99
get-cat-by-paw-id :
51
100
handler : rest_api/cat/get/handler.handle
@@ -57,8 +106,8 @@ functions:
57
106
enabled : true
58
107
ttlInSeconds : 3600
59
108
perKeyInvalidation :
60
- requireAuthorization : true
61
- handleUnauthorizedRequests : Ignore
109
+ requireAuthorization : true # default is true
110
+ handleUnauthorizedRequests : Fail # default is "IgnoreWithWarning"
62
111
cacheKeyParameters :
63
112
- name : request.path.pawId
64
113
- name : request.header.Accept-Language
0 commit comments