Are you needing a cache for your API? Maybe that response directive called Cache-Control could help you.

Lets to start with parameter max-age:

You can set an amount of time that content can be in cache.

How to use?

Cache-Control: max-age=3600

3600 (seconds) means how much time returned content from API request is going to last. In that case, it is going to last 1 hour.

The cache will be stored in client side so you do not have much control on it. Then be careful when using that paramater.

Now we’re going to speak about s-max-age:

It’s much like max-age but it has a different way to store cache, it store in server side.

How to use?

Cache-Control: s-max-age=3600

For both directives you can use parameters private or public. These values tell to the client or server to cache content in private or public way.

How to use?

Cache-Control: public, max-age=3600

Cache-Control: private, max-age=3600