How to define Cache-Control with predefined values in reusable responses


#1

Hi all,

I tried using RAML 1.0 to define responses headers for several endpoints but the best I could achieve was to define a /headers/noCache.raml file containing

Cache-Control:
  type: string
  default: no-cache, no-store, must-revalidate
Pragma: 
  type: string
  default: no-cache
Expires: 
  type: string
  default: "0"

and then to use that inside a trait

noCache:
  responses:
    200:
      headers: !include headers/noCache.raml
    206:
      headers: !include headers/noCache.raml

for finally use it inside my endpoints

/myendpoint:
  get:
    is[noCache]
    responses:
      200:
        body:
          ...

Aren’t there better ways to do that ; especially defining the header values as constant instead of proposed defaults values.

Thanks.