Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 3da93db

Browse files
committed
add Cache-control example
1 parent 9199fe6 commit 3da93db

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

source/scripting.rst

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ issued by :program:`curl`:
249249
}
250250
251251
252-
This uses a series of transformations
252+
This example uses a series of transformations
253253
to log the request's
254254
date, IP, URI,
255255
and all its headers:
@@ -261,5 +261,19 @@ and all its headers:
261261
"format": "`@timestamp=${new Date().toISOString()} ip=${remoteAddr} uri=${uri} ${Object.keys(headers).map(k => 'req.' + k + '=\"' + headers[k] + '\"').join(' ')}\n`"
262262
}
263263
264+
The next example will add the **Cache-Control** Header based on the HTTP Request method:
265+
266+
.. code-block:: json
267+
268+
{
269+
"action": {
270+
"pass": "applications/my_app",
271+
"response_headers": {
272+
"Cache-Control": "`${vars.method.startsWith('P') ? 'no-cache' : 'max-age=3600'}`"
273+
}
274+
}
275+
}
276+
277+
264278
For further reference,
265-
see the `njs documentation <https://nginx.org/en/docs/njs/>`__.
279+
see the `njs documentation <https://nginx.org/en/docs/njs/>`__.

0 commit comments

Comments
 (0)