<?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: queryFeatures returns cached features in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-returns-cached-features/m-p/1224436#M79087</link>
    <description>&lt;P&gt;One trick you can do is to make sure your query's where clause is always unique.&amp;nbsp; A common technique to return all features (and it is what it is) is to set the where clause to "1=1".&amp;nbsp; However, you could substitute any number into that.&amp;nbsp; To guarantee a unique number every time, which would defeat the browser's cache, you could use something like&amp;nbsp;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now" target="_self"&gt;Date.now&lt;/A&gt;() every time.&lt;/P&gt;&lt;P&gt;For example, if your &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html" target="_self"&gt;Query&lt;/A&gt; object had no &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where" target="_self"&gt;where&lt;/A&gt; value, you'd put:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var now = Date.now().toString();
query.where = now + "=" + now;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, if your &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html" target="_self"&gt;Query&lt;/A&gt; already had a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where" target="_self"&gt;where&lt;/A&gt; value, you'd put:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var now = Date.now().toString();
query.where = "(" + query.where + ") AND " + now + "=" + now;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Oct 2022 00:17:56 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2022-10-22T00:17:56Z</dc:date>
    <item>
      <title>queryFeatures returns cached features</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-returns-cached-features/m-p/1224288#M79079</link>
      <description>&lt;P&gt;This is in JavaScript API 4.21.&lt;/P&gt;&lt;P&gt;I am using queryFeatures to retrieve a recently updated feature to be highlighted and displayed on top of the feature layer from which the layer was queried. This used to work but now queryFeatures is returning old features from before the update. If I clear the browser's cache and reload the page then queryFeatures would return the updated version of the features. I verified from the API that the feature were updated when queryFeatures() was run. It is like the method was run against a cached version of the layer.&lt;/P&gt;&lt;P&gt;This is odd because it is only doing this for three of the layers. The other layers on the same service works fine.&lt;/P&gt;&lt;P&gt;Is there a way to run queryFeatures that forces the layer to get the data from the server and not the cache?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Oct 2022 16:05:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-returns-cached-features/m-p/1224288#M79079</guid>
      <dc:creator>MichaelWen_Timmons</dc:creator>
      <dc:date>2022-10-21T16:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: queryFeatures returns cached features</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-returns-cached-features/m-p/1224436#M79087</link>
      <description>&lt;P&gt;One trick you can do is to make sure your query's where clause is always unique.&amp;nbsp; A common technique to return all features (and it is what it is) is to set the where clause to "1=1".&amp;nbsp; However, you could substitute any number into that.&amp;nbsp; To guarantee a unique number every time, which would defeat the browser's cache, you could use something like&amp;nbsp;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now" target="_self"&gt;Date.now&lt;/A&gt;() every time.&lt;/P&gt;&lt;P&gt;For example, if your &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html" target="_self"&gt;Query&lt;/A&gt; object had no &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where" target="_self"&gt;where&lt;/A&gt; value, you'd put:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var now = Date.now().toString();
query.where = now + "=" + now;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, if your &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html" target="_self"&gt;Query&lt;/A&gt; already had a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where" target="_self"&gt;where&lt;/A&gt; value, you'd put:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var now = Date.now().toString();
query.where = "(" + query.where + ") AND " + now + "=" + now;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 00:17:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/queryfeatures-returns-cached-features/m-p/1224436#M79087</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-10-22T00:17:56Z</dc:date>
    </item>
  </channel>
</rss>

