Search code examples
restapicachingcache-control

REST API cache control for shared cache on server?


I would like to implement some caching on my REST API server so that clients can get faster responses from cached data that is shared among them.

However, I would still like to give clients the option of getting fresh data if they prefer it.

Most examples of the HTTP cache headers I have seen assume that the data is being cached locally on the client, but I will be storing it on my server in Redis.

What is the preferred method to expose cache control functionality to clients when the cache is server-side and shared?

Thank you.


Solution

  • Have you looked at the Cache-Control

    Cache-Control: max-age=
    Cache-Control: max-stale[=]
    Cache-Control: min-fresh=
    Cache-Control: no-cache
    Cache-Control: no-store
    Cache-Control: no-transform
    Cache-Control: only-if-cached