Set cache control header
-
Cache-control is an HTTP header used to specify browser caching policies in both client requests and server responses.
-
Policies include how a resource is cached, where it’s cached and its maximum age before expiring (i.e., time to live)
For example,
cache-control: max-age=120 means that the returned resource is valid for 120 seconds, after which the browser has to request a newer version.
-
The public (cacheResponseDirective) response directive indicates that a resource can be cached by any cache.
-
The private (cacheResponseDirective) response directive indicates that a resource is user specific - it can still be cached, but only on a client device. For example, a web page response marked as private can be cached by a desktop browser, but not a content delivery network (CDN).
Response
Set cache control header
Example response
{
"data": {
"headers": {
"access-control-allow-credentials": "true",
"access-control-allow-origin": "*",
"cache-control": "private, max-age=120",
"x-powered-by": "Express"
}
},
"message": "Cache control header has been set",
"statusCode": 200,
"success": true
}