Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ distribution:
pathPatterns:
/static/images: # route any /static/images requests to https://my-assets.com
ttl: 10
allowedHttpMethods: ['GET', 'HEAD'] # optional
```

#### Lambda@Edge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Object {
"Items": Array [
"GET",
"HEAD",
"POST",
],
"Quantity": 2,
"Quantity": 3,
},
"Compress": true,
"DefaultTTL": 10,
Expand Down
3 changes: 2 additions & 1 deletion __tests__/origin-with-path-pattern.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ describe('Input origin with path pattern', () => {
url: 'https://exampleorigin.com',
pathPatterns: {
'/some/path': {
ttl: 10
ttl: 10,
allowedHttpMethods: ['GET', 'HEAD', 'POST']
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/getCacheBehavior.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = (pathPattern, pathPatternConfig, originId) => {
const { ttl } = pathPatternConfig
const { ttl, allowedHttpMethods } = pathPatternConfig
const allowedMethods = allowedHttpMethods || ['GET', 'HEAD']

return {
ForwardedValues: {
Expand All @@ -25,8 +26,8 @@ module.exports = (pathPattern, pathPatternConfig, originId) => {
},
ViewerProtocolPolicy: 'https-only',
AllowedMethods: {
Quantity: 2,
Items: ['GET', 'HEAD'],
Quantity: allowedMethods.length,
Items: allowedMethods,
CachedMethods: {
Items: ['GET', 'HEAD'],
Quantity: 2
Expand Down