Skip to content

CACHE_EXPIRES_IN ​

Also known as

cache_expires (with or without @ prefix)

Set cache expiration time for cached endpoints.

Syntax ​

code
@cache_expires_in <interval>

Uses interval format. Common examples:

FormatMeaning
10s10 seconds
5m5 minutes
1h1 hour
1d1 day
1w1 week

Examples ​

Short Cache (10 seconds) ​

sql
sql
comment on function get_live_data() is
'HTTP GET
@cached
@cache_expires_in 10s';

Medium Cache (5 minutes) ​

sql
sql
comment on function get_dashboard_stats() is
'HTTP GET
@cached
@cache_expires_in 5m';

Long Cache (1 hour) ​

sql
sql
comment on function get_static_config() is
'HTTP GET
@cached
@cache_expires_in 1h';

Daily Cache ​

sql
sql
comment on function get_daily_report() is
'HTTP GET
@cached
@cache_expires_in 1d';

See Also ​

Comments