pandastrike / panda-sky

Publish HTTP APIs to the Web just like static sites!
MIT License
4 stars 0 forks source link

HTTP Caching Helpers #22

Open freeformflow opened 8 years ago

freeformflow commented 8 years ago

This is a little bit tricky. Currently we have a CloudFront distribution in front of the API Gateway to provide a custom URL with HTTPS backed by a cert from ACM. We're operating on the assumption that Gateway will support ACM certs any day now. So perhaps it's best to apply our efforts within the Gateway itself.

In thinking about #11, we should have a way to provide expected caching related headers for API responses so we don't have to execute lambdas repeatedly. That means using the lambdas to set cache-control and Etag headers, and then supporting those headers in the Gateway's response integration (is this possible?).

dyoder commented 8 years ago

I think this is possible, from what I read in the docs. We do have to use VTL to take the headers from the Lambda response and set them in the HTTP response.

I think this is just some wrapper functions. We can specify caching policies in the API definition. But that means that somehow the Lambda helpers for this need access to the API definition.

Outside of that, it's pretty straightforward. I've been considering implementing this for awhile now. The only thing we need from the handler itself is the last modified date. Everything else can be pretty much automatic based on the policy.