The Cache Control setting for a hosted feature layer (item) allows you to optimize the number of query
requests that are directed to a feature layer in a feature service. Using the CDN cache can significantly decrease network latency and improve performance when there are high demands on feature services at global scales.
What is the CDN cache?
The CDN cache is a content delivery network (CDN) supported by ArcGIS Location Platform and ArcGIS Online that is designed to optimize service performance and reduce service requests. To use the CDN cache with ArcGIS Location Platform, the feature layer sharing level must be Owner (private). To use the CDN cache with ArcGIS Online, the sharing level must be Everyone (public).
How the CDN cache works
Applications make query
requests to a feature layer in a feature service when you display a map with the layer, interact with the map (and layer), or make queries directly to the layer. The CDN caches the data returned from the service for requests for a length of time (cache
) that you specify in the setting. The default value is 30 seconds. Therefore, when the same requests are made to the service within that time, the CDN cache can provide the response. Once the maximum cache age is reached, the cache is refreshed and the data is synchronized with the service. This ensures the cache stays up to date when the data is being updated by your application or other applications.
If the data is not being updated frequently, you should set the cache timeout to the longest setting possible (1hr). If it is being edited frequently, set the interval to be slightly higher than the time interval the data is being edited. The longer the cache timeout, the better the overall performance will be.
How to manage CDN cache settings
The steps to manage service settings are:
-
Sign into a data management tool with your ArcGIS account:
- Go to ArcGIS.com and sign in to your portal (ArcGIS Location Platform or ArcGIS Online)
- Find the item.
- Use the settings tab of the item page to change the cache control settings.
Code examples
You can use data management tools to manage the CDN cache settings of a hosted feature layer or you can use the ArcGIS REST APIs. The following examples illustrate how to programmatically set the cache max age of a hosted feature layer.
Set the cache max age
This example uses the update
admin operation to set the cache
with a value in seconds between zero and one hour (3600
).
Request
POST https://{host}/rest/admin/services/{service_name}/FeatureServer/updateDefinition HTTP/1.1
f=json
&token={access_token}
&updateDefinition = "{
"hasStaticData": false,
"capabilities": "Query,Editing,Create,Update,Delete",
"layerOverridesEnabled":true,
"editorTrackingInfo": {
"enableEditorTracking":false,
"enableOwnershipAccessControl": false,
"allowOthersToUpdate": true,
"allowOthersToQuery": true,
"allowAnonymousToQuery": true,
"allowAnaonymousToDelete": true
},
"cacheMaxAge:3600"
}"
Response (JSON)
{"success":true}
Tutorials
Import data to create a feature layer
Use data management tools to import files and create a feature layer in a feature service.
Define a new feature layer
Use data management tools to define and create a new empty feature layer in a feature service.
Manage a feature layer
Use a hosted feature layer item to set the properties and settings of a feature layer in a feature service.
Create a vector tile service
Use data management tools to create a new vector tile service from a feature service.
Create a map tile service
Use ArcGIS Online or scripting APIs to publish a map tile service.
Workflows
Create a feature service for an app
Learn how to import parcel data, create and style a feature layer, and then access the features in an app.
Create a feature layer view for an editor app
Learn how to import parcel data, create and style a feature layer view, and then access the features in an editing app.
Create a vector tile service for an app
Learn how to import parcel data, style a feature layer, and then create a vector tile service for an app.
Create a map tile service for an app
Learn how to import contour data, style a feature layer, and create a map tile service for an app.
Services
Feature service
Add, update, delete, and query feature data.
Vector tile service
Store and access vector tile data.
Map tile service
Store and access map tile data.
Image service
Store and access imagery and raster data.
API support
Use data management tools or Client APIs to create, manage, and access data services. The table below outlines the level of support for each API.
- 1. Use portal class and direct REST API requests
- 2. Access via ArcGIS REST JS
- 3. Requires manually setting styles for renderers