From d77da6bd49ce19c3fb9472271e8f58ebf4dcd041 Mon Sep 17 00:00:00 2001 From: Alexis Panagiotopouos Date: Fri, 12 Mar 2021 13:02:42 +0200 Subject: [PATCH] Update api.rst Changed SET LOCAL to SELECT set_config( ... ) so that the value of the header can be dynamically calculated. Supported in versions 9.6 and above. --- api.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api.rst b/api.rst index 548c7094d..4c72eb03a 100644 --- a/api.rst +++ b/api.rst @@ -1530,9 +1530,9 @@ PostgREST reads the ``response.headers`` SQL variable to add extra headers to th -- tell client to cache response for two days - SET LOCAL "response.headers" = - '[{"Cache-Control": "public"}, {"Cache-Control": "max-age=259200"}]'; - + SELECT set_config('response.headers', + '[{"Cache-Control": "public"}, {"Cache-Control": "max-age=259200"}]', true); + Notice that the variable should be set to an *array* of single-key objects rather than a single multiple-key object. This is because headers such as ``Cache-Control`` or ``Set-Cookie`` need to be repeated when setting multiple values and an object would not allow the repeated key. .. note::