Changelog v3.3.1 (2025-01-14)
Version 3.3.1 (2025-01-14)
Proxy Response Caching
Added support for caching responses from passthrough proxy endpoints. Previously, caching only worked with endpoints that executed database functions. Now, proxy endpoints that forward requests to upstream services can also leverage the caching system.
Usage:
sql
create function get_external_data()
returns void
language plpgsql as $$ begin null; end; $$;
comment on function get_external_data() is '
HTTP GET
proxy
cached
cache_expires_in 5 minutes
';Features:
- Cache lookup happens before proxy request is sent
- On cache hit, response is returned immediately without calling upstream service
- Cached proxy responses preserve: status code, body, content type, and headers
- Supports cache key parameters for parameter-based caching
- Supports cache expiration with
cache_expires_inannotation
Example with cache key:
sql
create function get_user_profile(_user_id text)
returns void
language plpgsql as $$ begin null; end; $$;
comment on function get_user_profile(text) is '
HTTP GET
proxy https://api.example.com/users
cached _user_id
cache_expires_in 1 hour
';This is useful for:
- Reducing load on upstream services
- Improving response times for frequently accessed data
- Rate limiting protection for external API calls
Optional @ Prefix for Comment Annotations
Added support for optional @ prefix on all NpgsqlRest-specific comment annotations. This provides better visual distinction and consistency with .http file conventions.
Both syntaxes are equivalent and can be mixed freely:
sql
-- Without @ prefix (existing syntax - still works)
comment on function my_func() is '
HTTP GET
authorize
cached
raw
';
-- With @ prefix (new syntax)
comment on function my_func() is '
HTTP GET
@authorize
@cached
@raw
';
-- Mixed (both work together)
comment on function my_func() is '
HTTP GET
@authorize
cached
@timeout 30s
';Notes:
- The
@prefix is optional - existing code without@continues to work unchanged - HTTP RFC standard annotations (headers with
Name: valuesyntax) do not use the@prefix - This applies to all NpgsqlRest-specific annotations:
authorize,cached,raw,disabled,login,logout,proxy,upload,validate, etc.