<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set and update cache control longest time (cacheMaxAge) for layers and tables in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/set-and-update-cache-control-longest-time/m-p/1541644#M10693</link>
    <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayerCollection

items = user.items()
item = items[0]
flc = FeatureLayerCollection.fromitem(item)
flc.manager.update_definition({"cacheMaxAge":600})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This appears to round up to 15 minutes, however, because I think only certain intervals are supported.&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2024 20:46:26 GMT</pubDate>
    <dc:creator>EarlMedina</dc:creator>
    <dc:date>2024-09-23T20:46:26Z</dc:date>
    <item>
      <title>Set and update cache control longest time (cacheMaxAge) for layers and tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/set-and-update-cache-control-longest-time/m-p/1539783#M10681</link>
      <description>&lt;P&gt;Using ArcGIS Online user interface, it is possible to set / update&amp;nbsp;Cache Control&amp;nbsp;longest time. Default is 30 seconds, longest is 1 hour.&lt;/P&gt;&lt;P&gt;This can be done under&amp;nbsp;Cache Control in Settings tab for&amp;nbsp;Feature Layer (hosted) and&amp;nbsp;Table (hosted) with Source: Feature Service.&lt;/P&gt;&lt;P&gt;I am publishing tables and feature layers programmatically using&amp;nbsp;ArcGIS API for Python. I can't find a way to set the&amp;nbsp;Cache Control value when publishing or update it later.&lt;/P&gt;&lt;P&gt;I did find it as property which I can access, but not update. Simplified example of code variations I have tried:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Printing&amp;nbsp;cacheMaxAge does print out the actual value set / updated via interface (in seconds, e.g. 3600 for 1 hour). Result value is "{'success': True}". But the cacheMaxAge value does not update.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;How can I set and/or update Cache Control (cacheMaxAge) using&amp;nbsp;ArcGIS API for Python?&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 18 Sep 2024 00:35:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/set-and-update-cache-control-longest-time/m-p/1539783#M10681</guid>
      <dc:creator>miro_aus</dc:creator>
      <dc:date>2024-09-18T00:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Set and update cache control longest time (cacheMaxAge) for layers and tables</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/set-and-update-cache-control-longest-time/m-p/1541644#M10693</link>
      <description>&lt;P&gt;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:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayerCollection

items = user.items()
item = items[0]
flc = FeatureLayerCollection.fromitem(item)
flc.manager.update_definition({"cacheMaxAge":600})&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This appears to round up to 15 minutes, however, because I think only certain intervals are supported.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2024 20:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/set-and-update-cache-control-longest-time/m-p/1541644#M10693</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2024-09-23T20:46:26Z</dc:date>
    </item>
  </channel>
</rss>

