CACHE_EXPIRES_IN
Set cache expiration time for cached endpoints.
Keywords
cache_expires, cache_expires_in
Syntax
cache_expires_in <interval>Uses PostgreSQL interval format.
Interval Format
| Format | Meaning |
|---|---|
10s | 10 seconds |
5m | 5 minutes |
1h | 1 hour |
1d | 1 day |
1w | 1 week |
Examples
Short Cache (10 seconds)
sql
comment on function get_live_data() is
'HTTP GET
cached
cache_expires_in 10s';Medium Cache (5 minutes)
sql
comment on function get_dashboard_stats() is
'HTTP GET
cached
cache_expires_in 5m';Long Cache (1 hour)
sql
comment on function get_static_config() is
'HTTP GET
cached
cache_expires_in 1h';Daily Cache
sql
comment on function get_daily_report() is
'HTTP GET
cached
cache_expires_in 1d';Related
- Cache Options configuration - Configure cache backend
- Comment Annotations Guide - How annotations work
- Configuration Guide - How configuration works
Related Annotations
- CACHED - Enable caching