There are many ways to exclude a URL from caching in CloudFront. One method can be used appropriate maxage response headers. If you are using Serverless framework, you might be using either serverless.yml
or serverless.js
file.
In serverless.js
file, you can mention the path of url and exclude it from caching using below technique.
inputs: {
cloudfront: {
distributionId: <DISTRIBUTION_ID>,
"/path-to-url": {
minTTL: 0,
maxTTL: 0,
defaultTTL: 0,
},
//...
}