This functionality is available for read requests only in the following methods:
Get Entity: Method: /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITY
Get Entity Set: Method: /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET
Get Expanded Entity: Method: /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY
Get Expanded Entity Set: Method: /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET
Get Stream (Read Media Resource): Method: /IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_STREAM
To be able to use this functionality the application developer must adapt the implementation in these methods, by filling the following export parameters that are available in each of the methods above:
ES_RESPONSE_CONTEXT-MAX_AGE
ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT
ES_RESPONSE_CONTEXT-LAST_MODIFIED
ES_RESPONSE_CONTEXT-IS_NOT_MODIFIED
To read the HTTP request header if-modified-since, the application developer can use method /IWBEP/CL_MGW_REQUEST=>GET_IF_MODIFIED_SINCE().
Example:
DATA lv_if_modified_since TYPE tzntstmps. lv_if_modified_since = io_tech_request_context->get_if_modified_since( ).
MAX_AGE
If export parameter ES_RESPONSE_CONTEXT-MAX_AGE is set to a value, then SAP Gateway will generate the HTTP response header cache-control with a max-age directive.
Example:
cache-control: max-age=3600
Note that if export parameter ES_RESPONSE_CONTEXT-MAX_AGE is set to a value, you must also set the export parameter ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT to ‘-’ (meaning ‘can be cached’).
DO_NOT_CACHE_ON_CLIENT
Default behavior: If export parameter ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT is left as undefined (that is, set to ‘ ‘) then the system automatically sets the default of ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT to the value ‘X’ and SAP Gateway will generate the following HTTP response header:
cache-control: no-store, no-cache
If export parameter ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT is set to 'X', then SAP Gateway will generate the following HTTP response header:
cache-control: no-store, no-cache
To enable caching the export parameter ES_RESPONSE_CONTEXT-DO_NOT_CACHE_ON_CLIENT must be set to ‘-’ and export parameter ES_RESPONSE_CONTEXT-MAX_AGE must be set to a value.
LAST_MODIFIED
The export parameter ES_RESPONSE_CONTEXT-LAST_MODIFIED should be filled with a time stamp that indicates when the last change of the related business data occurred.
If the ES_RESPONSE_CONTEXT-LAST_MODIFIED is filled with a time stamp, then SAP Gateway will generate the HTTP response header last-modified with the related date.
Example:
last-modified: Tue, 27 Nov 2012 09:41:40 GMT
Additionally, if the export parameter ES_RESPONSE_CONTEXT-LAST_MODIFIED contains a time stamp that is older than the HTTP request header if-modified-since, then an HTTP 304 response (‘not modified’) will be sent by SAP Gateway. In this case, an HTTP response header last-modified will not be sent.
IS_NOT_MODIFIED
The export parameter ES_RESPONSE_CONTEXT-IS_NOT_MODIFIED may be set to ABAP_TRUE only in case LAST_MODIFIED of the application data is older than the time stamp in HTTP request header if-modified-since. In such cases, the related application data is up-to-date and does not need to be sent at all. SAP Gateway will then generate an HTTP 304 response (‘not modified’).
It is also possible to use method /iwbep/if_mgw_conv_srv_runtime~check_if_is_not_modified( ) to calculate the value for export parameter ES_RESPONSE_CONTEXT-IS_NOT_MODIFIED.
Example:
DATA lv_if_modified_since TYPE tzntstmps. lv_if_modified_since = io_tech_request_context->get_if_modified_since( ). es_response_context-is_not_modified = /iwbep/if_mgw_conv_srv_runtime~check_if_is_not_modified( iv_if_modified_since = lv_if_modified_since iv_last_modified = es_response_context-last_modified ).
An HTTP 304 response (‘Not Modified’) will be set if one of the following cases applies:
The export parameter ES_RESPONSE_CONTEXT-IS_NOT_MODIFIED is set to ABAP_TRUE.
The export parameter ES_RESPONSE_CONTEXT-LAST_MODIFIED contains a time stamp that is older than the HTTP request header if-modified-since.