Skip to content

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

FormatMeaning
10s10 seconds
5m5 minutes
1h1 hour
1d1 day
1w1 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';

Released under the MIT License.