REST Response > Remove/override caching headers

nickg111
Kilo Contributor

Hi all,

Version: Geneva

I want to be able to cache a REST response for 5 minutes... I've tried using setHeaders(..) (there's no removeHeaders(..)), but it looks as though ServiceNow has hardcoded the `Cache-Control`, `Pragma` and `Expires` HTTP headers in the response. Is there anyway to remove `Pragma` and `Expires`, and replace `Cache-Control` with a new value?

i.e.

I am currently setting headers like so:

response.setHeaders({

      "Access-Control-Allow-Origin": "*",

      "Access-Control-Allow-Methods": "POST, GET, OPTIONS, DELETE",

      "Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Authorization",

      "Cache-Control": "max-age=300",

      "Pragma": null,

      "Expires": null

});

However, I (still) get the following headers in the response:

Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization

Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE

Access-Control-Allow-Origin: *

Cache-control: no-cache,no-store,must-revalidate,max-age=-1

Content-Encoding: gzip

Content-Type: application/json;charset=UTF-8

Date: Mon, 10 Jul 2017 01:18:40 GMT

Expires: 0

Pragma: no-store,no-cache

Server: ServiceNow

Strict-Transport-Security: max-age=63072000; includeSubDomains

Transfer-Encoding: chunked

Fyi, kiki330611, ben_amiot, arthurcheung

2 REPLIES 2

kiki330611
Kilo Expert

I have exactly the same question!! Hope someone knows the answer!


Not on those exact same properties, but we've had similar (unresolved) issues with other properties on the header in the past. Would be interested to see the solution.