我的数据库仅在下午1点到2点之间获取新数据。用户来回跳转,经常多次看同一件事,我想用缓存来减少网络负载。我的回复类型是:
source_type_collection_item
Executes a SQL Query returning one row of data into a ORDS Standard JSON representation.
Available when the HTTP method is GET.
Result Format: JSON
具有多个嵌套CURSORS的单行SYS_REFCURSOR响应。
FUNCTION my_func RETURN SYS_REFCURSOR
AS
my_cursor SYS_REFCURSOR;
BEGIN
OPEN my_cursor FOR
SELECT value, CURSOR(SELECT value_2, CURSOR(SELECT ... FROM table)
...
我想根据服务器时间设置不同的缓存控制:
问题在于我无法弄清楚如何为返回HTTP GET的ORDS端点设置缓存 。我有一个工作正常的无关的PL / SQL服务
source_type_plsql :-
Executes an anonymous PL/SQL block and transforms any OUT or IN/OUT parameters into a JSON representation.
Available only when the HTTP method is DELETE, PUT, or POST.
Result Format: JSON
使用已定义的参数:
ords.define_parameter(
p_module_name => l_module_name,
p_pattern => l_pattern,
p_method => l_method,
p_name => 'Cache-Control',
p_bind_variable_name => 'cache_control',
p_source_type => 'HEADER',
p_param_type => 'STRING',
p_access_method => 'OUT',
p_comments => '');
但这不适用于GET案例,因为:
我能想到的唯一选择是Tomcat中的静态缓存设置而不是ORDS。
<filter>
<filter-name>ExpiresFilter</filter-name>
<filter-class>org.apache.catalina.filters.ExpiresFilter</filter-class>
<init-param>
<param-name>ExpiresByType application/json</param-name>
<param-value>access plus 30 minutes</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>ExpiresFilter</filter-name>
<url-pattern>/ords/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
但出于多种原因,这是不可取的: