Scenario: I have two endpoint.resource_functions. They both return a javascript resource. One returns the dev version (the active row that can be changed anytime) and the other function returns an immutable module that can be cached forever. However, if the immutable javascript module doesn't exist, I want to fallback to returning the dev version.
widget.dev_version() {
return SELECT js from ...;
}
widget.cached_version() {
if (EXISTS ...) {
return SELECT cached_js from ...;
} else {
return widget.dev_version();
}
}
The headers cannot be a field in endpoint.resource_function because we don't want to cache the fallback dev version.
Rather, we can return a record from the resource function
select content, headers from your_function(...) as (content text, headers jsonb)
Scenario: I have two
endpoint.resource_function
s. They both return a javascript resource. One returns the dev version (the active row that can be changed anytime) and the other function returns an immutable module that can be cached forever. However, if the immutable javascript module doesn't exist, I want to fallback to returning the dev version.The headers cannot be a field in
endpoint.resource_function
because we don't want to cache the fallback dev version.Rather, we can return a record from the resource function