Using ArcGIS Online user interface, it is possible to set / update Cache Control longest time. Default is 30 seconds, longest is 1 hour.
This can be done under Cache Control in Settings tab for Feature Layer (hosted) and Table (hosted) with Source: Feature Service.
I am publishing tables and feature layers programmatically using ArcGIS API for Python. I can't find a way to set the Cache Control value when publishing or update it later.
I did find it as property which I can access, but not update. Simplified example of code variations I have tried:
items = user.items()
item = items[0]
table = item.tables[0]
print(table.properties.cacheMaxAge)
cache_definition = {"cacheMaxAge": 600}
result = table.manager.update_definition(cache_definition)
# result = table.manager.add_to_definition(cache_definition)
print(result)
Solved! Go to Solution.
The way you do this is at the Feature Service level. In the API, it is done via a FeatureLayerCollection object. So, you would update your example to something like this:
from arcgis.features import FeatureLayerCollection
items = user.items()
item = items[0]
flc = FeatureLayerCollection.fromitem(item)
flc.manager.update_definition({"cacheMaxAge":600})
This appears to round up to 15 minutes, however, because I think only certain intervals are supported.
The way you do this is at the Feature Service level. In the API, it is done via a FeatureLayerCollection object. So, you would update your example to something like this:
from arcgis.features import FeatureLayerCollection
items = user.items()
item = items[0]
flc = FeatureLayerCollection.fromitem(item)
flc.manager.update_definition({"cacheMaxAge":600})
This appears to round up to 15 minutes, however, because I think only certain intervals are supported.