Custom data feature service responses can be cached so that when a client sends the same query again, a saved response can be quickly returned rather than processing the request again. This saves a significant amount of time by eliminating the need to repeatedly contact the custom data feed's remote data source. Response caching can improve response times, alleviate pressure on the custom data server, and improve a user's experience when working with read-only data that changes infrequently. Configuring the caching option applies to all layers in the custom data feature service.
How Response Caching Works
Enabling response caching is an administrative configuration option that specifies that when a client sends a feature layer query, if that identical query has been sent previously and valid response for that query has been stored in the object store, then the stored response will be returned to the client rather than processing the request. Response caching is disabled by default for custom data feature services. Enabling response caching for a custom data feature service updates the value of the supports property to true on all layers. This informs ArcGIS applications and custom applications that cached responses can be requested. You can confirm that a cached response has been returned to the client by inspecting the response headers for either x-esri-cache-hint-features or x-esri-ftiles-cache-compress.
Enabling and Disabling the Response Cache
Follow these steps to enable response caching:
-
Open ArcGIS Server Administrator or ArcGIS Enterprise Admin if working with Kubernetes.
-
Navigate to Services and select the custom data feature service.
-
Click Edit.
-
In the Service Properties window, update the
customproperty value toData Service Info.cache.enabled trueand thecustomproperty value to an integer representing the number of days the cache should be valid before expiring. See the example below.Data Service Info.cache.expiration Use dark colors for code blocks Copy "customDataServiceInfo": { "cache": { "expiration": 1, "enabled": true } }
Cache Invalidation
The response cache entries will expire based on the number of days that you set in the expiration property. Each time a cached response is created, it is time stamped and considered valid for the specified number of days. Each request that results in a cache hit will return the cached response until it expires. When the cache expires, it becomes invalid, and the next cache hit will not return the response cache. Instead, the request will be processed and return a fresh response. The invalidated cache will be replaced with a new cached response.
Cache Purge
Response cache for a custom data feature service can be deleted in three ways:
- Deleting the service
- Setting the
enabledproperty tofalseon the custom data feature service's JSON - Scheduled or manual running of object store clean up utilities