Skip to Content
0
Mar 25, 2019 at 11:11 AM

How to enable caching for OData service?

996 Views Last edit May 21, 2020 at 03:48 PM 2 rev

Hello,

We have an OData service defined using an .xsodata file in an MTA. We are using SAP HANA Service in SAP Cloud Foundry environment. The OData service is taking a bit of time in execution and we were wondering to enable caching of content using the ETag support. The issue is that the service doesn't seem to be sending the ETag attribute in the HTTP Response Header to enable caching by the browser. How do make the OData service send the ETag?

The service code looks like this:

service {
    "sample.odata.models::customer" as "CalcView"
    keys generate local "ID"
    aggregates always; 
    entity "sample.odata.models::customer" as "EtagKeys"
    key ("KEY_00") concurrencytoken;
}
settings {  
  support null; 
  content cache-control "no-cache"; 
  metadata cache-control "max-age=86401,must-revalidate"; 
}

Thanks!