demo: per-path cache TTLs via cache rules
two endpoints, two different cache rules. /api/cache-short
is cached for 1 second at the edge (basically un-cached). /api/cache-forever
is cached for 24 hours. the button fires both back-to-back three times
so you can watch generatedAt change on one and stay pinned
on the other.
click the button…
# rules
SITE_cache_short | /api/cache-short → edge TTL 1s |
SITE_cache_forever | /api/cache-forever → edge TTL 86400s |
# from your terminal
# cache-short: every hit generates a new time
for i in 1 2 3; do
sleep 2
curl -s "https://rhocfsandbox.com/api/cache-short" | grep generatedAt
done
# cache-forever: same time on repeat
for i in 1 2 3; do
curl -s "https://rhocfsandbox.com/api/cache-forever" | grep generatedAt
done