Endpoints caching with serverless 1.x

Hi,

So we’ve are migrating backend logic into serverless framework.
We have already migrated worker servers and it works beautifully :slight_smile:

However with API endpoints things are more complicated as we need to address the issue of performance.
We would like to be able to specify (preferably in serverless.yml) caching configuration of each endpoint (including query params caching where needed).

We’ve seen examples from serverless 0.x but none from the 1.x versions.

Any help would be much appreciated… :slight_smile:

I’m not familiar with 0.x, and haven’t seen this in 1.x yet.

Can you give concrete examples/requirements?

No problem, I’ll provide an example:

Suppose I have a GET method endpoint which receives and query parameter.
Based on said query param it run logic, access DB, storage etc. and produces a response.

(Very) Basic illustration:
GET /process?q=1 ==> HTTP 200 OK “response for q=1 is …”

Now, as the response in the same for every given query param (when q=1 it always produces same result etc.), I don’t want to calculate the response each time by invoking a lambda function. I’d like the API gateway to issue a response from cache. Thus reducing latency and providing better performance.

Also. I’d like to configure caching properties for each endpoint specifically and not in the AWS console but in serverless.yml.

Hope It helps to clarify the issue.

BTW
you can see an article discussing these features in version 0.x here

I would love to have this functionality also!

1 Like

Yan Cui from Space Ape Games has written a blog post on how to get caching working in serverless 1.x, haven’t attempted it myself but looks quite thorough.

https://medium.com/@theburningmonk/serverless-1-x-enable-api-gateway-caching-on-request-parameters-894b31762068

1 Like