Skip to content

Commit cc4f920

Browse files
committed
docs: add more details to jwt cache
1 parent 0df10f5 commit cc4f920

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docs/references/auth.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,19 @@ It goes as follows:
204204
JWT Cache
205205
---------
206206

207-
PostgREST validates ``JWTs`` on every request. Signature validation (especially asymmetric such as RSA) is slow and we can cache ``JWT`` validation results to avoid this performance overhead.
207+
JWT signature validation (specially :ref:`asym_keys` such as RSA) is slow, we can cache ``JWT`` validation results to avoid this performance overhead.
208208

209-
JWT caching is automatically enabled unless the config :code:`jwt-cache-max-entries` is set to 0.
209+
The JWT cache is bounded and uses the `SIEVE algorithm <https://cachemon.github.io/SIEVE-website>`_ for efficient eviction. The cache is enabled by default and can be configured with :ref:`jwt-cache-max-entries`.
210210

211-
See :ref:`jwt-cache-max-entries` for more details.
211+
It's recommended to leave the JWT cache enabled as our load tests indicate ~20% more throughput for simple GET requests when using it. This while reducing CPU utilization in exchange for a bit more memory.
212+
213+
:ref:`jwt_cache_metrics` are available.
212214

213215
.. note::
214216

215-
You can use the :ref:`server-timing_header` to see the effect of JWT caching.
217+
- If the ``jwt-secret`` is changed and the config is reloaded, the JWT cache will reset.
218+
- Invalid JWTs (such as expired ones), are cached. This to ensure responses stays fast under failure cases.
219+
- You can use the :ref:`server-timing_header` to see the peformance benefit of JWT caching.
216220

217221
.. _jwt_role_extract:
218222

docs/references/observability.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ pgrst_db_pool_max
201201

202202
Max pool connections.
203203

204+
.. _jwt_cache_metrics:
205+
204206
JWT Cache Metrics
205207
-----------------
206208

0 commit comments

Comments
 (0)