add: add "Vary" header to responses

Co-authored-by: Steve Chavez <stevechavezast@gmail.com>
This commit is contained in:
Andrei Dziahel
2026-03-16 09:55:20 -05:00
committed by Steve Chavez
co-authored by Steve Chavez
parent d5df12c9c2
commit 1f54e2accc
8 changed files with 86 additions and 10 deletions
+1
View File
@@ -15,6 +15,7 @@ BOM
Bytea
Cardano
cd
CDNs
centric
CLI
CMS
+1
View File
@@ -21,6 +21,7 @@ PostgREST exposes three database objects of a schema as resources: tables, views
api/aggregate_functions.rst
api/openapi.rst
api/preferences.rst
api/vary_header.rst
api/*
.. raw:: html
+16
View File
@@ -0,0 +1,16 @@
.. _vary_header:
Vary Header
===========
In order to assist caching proxies and CDNs, PostgREST includes a ``Vary`` header of value
``Accept, Prefer, Range`` in its responses which should fit most of the bills. As any other
response header, it's available for override
by updating ``response.headers`` GUC variable accordingly, for example:
.. code-block:: postgres
-- Override the Vary header to include Accept, Prefer and X-Test-Vary headers
perform set_config('response.headers', '[{"Vary": "Accept, Prefer, X-Test-Vary"}]', true);
In this case PostgREST will use provided value verbatim.