<?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: Disable Caching on FeatureLayer.refresh() in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457109#M42193</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've also noticed this behavior when using Safari (and thus all iOS devices) where calling refresh() on a FeatureLayer does not actually refresh the features on the client. Examining the request shows that the querystring contains neither a timestamp (_ts) nor a dojo.preventCache parameter. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My solution is to modify the request with a preventCache option before it is sent to the server. I set this up in my initialization method. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
esri.setRequestPreCallback(function (ioArgs) {&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ioArgs.url.indexOf("FeatureServer") &amp;gt; -1 &amp;amp;&amp;amp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.url.indexOf("returnGeometry=true") &amp;gt; -1) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.preventCache = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ioArgs;
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interestingly, the featurelayer in the Silverlight API has an option to disable client caching. Might be nice to see that capability ported to the JSAPI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:21:10 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T20:21:10Z</dc:date>
    <item>
      <title>Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457106#M42190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to disable caching on an OnDemand mode FeatureLayer? When I use the .refresh() method it refreshes, but more often than not the actual data returned isn't different, and I know that the layer has been updated. Zooming updates the data at the new zoom level, but on returning to the original scale the features are back to what was originally loaded.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried manually updating the url of the FeatureLayer with a timestamped querystring via two methods:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var newtimestamp = new Date().getTime();
layer.url = layer.url.replace(/nocache=.*/,'nocache='+newtimestamp);
layer.refresh();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
var newtimestamp = new Date().getTime();
layer._url.query.nocache = newtimestamp;
layer.refresh();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Neither actually changes the URL hit by the layer.refresh() though. Any suggestion on what method/variable to use to do this, or a different way to get around this caching issue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Apr 2012 13:12:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457106#M42190</guid>
      <dc:creator>JamesCornwell-Shiel</dc:creator>
      <dc:date>2012-04-09T13:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457107#M42191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As a brief update, I have somewhat resolved this by setting the web server's CacheControl header to NO-CACHE. I'll have to filter this down to just feature services, but that should be fine. That said, there may be times when I don't have control over the server, so the question still stands as to whether there's a JS-side way to handle the issue of service caching.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Apr 2012 13:16:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457107#M42191</guid>
      <dc:creator>JamesCornwell-Shiel</dc:creator>
      <dc:date>2012-04-09T13:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457108#M42192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm interested in this topic too. It's very important to disable the caching when you, for example, change dynamically the definition expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please someone reply!xD&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you everyBody&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Apr 2012 05:26:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457108#M42192</guid>
      <dc:creator>demdeberanz</dc:creator>
      <dc:date>2012-04-10T05:26:24Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457109#M42193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've also noticed this behavior when using Safari (and thus all iOS devices) where calling refresh() on a FeatureLayer does not actually refresh the features on the client. Examining the request shows that the querystring contains neither a timestamp (_ts) nor a dojo.preventCache parameter. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My solution is to modify the request with a preventCache option before it is sent to the server. I set this up in my initialization method. &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
esri.setRequestPreCallback(function (ioArgs) {&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ioArgs.url.indexOf("FeatureServer") &amp;gt; -1 &amp;amp;&amp;amp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.url.indexOf("returnGeometry=true") &amp;gt; -1) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.preventCache = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; return ioArgs;
});
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interestingly, the featurelayer in the Silverlight API has an option to disable client caching. Might be nice to see that capability ported to the JSAPI.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:21:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457109#M42193</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T20:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457110#M42194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I agree, setting "ioArgs.preventCache = true" in a RequestPreCallback function as suggested above seems to have resolved an issue I was having in IE8.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Jun 2012 13:39:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457110#M42194</guid>
      <dc:creator>ThomasDickerson</dc:creator>
      <dc:date>2012-06-12T13:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457111#M42195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Seems that the problem persists in IE9. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It works fine in Firefox18.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can any one can verify that in IE9?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Please share if you have a solution to disable caching in IE9?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Jan 2013 14:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457111#M42195</guid>
      <dc:creator>DimitarKolev</dc:creator>
      <dc:date>2013-01-18T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457112#M42196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;my bad:rolleyes:. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did not pay attention that the &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ioArgs.preventCache = true;&lt;/PRE&gt;&lt;SPAN&gt; was never executed because ioArgs.url did not have indexOf("returnGeometry=true"). &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I dont know if this is a change in ArcGIS 10.1 or else. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;After examining the properties of ioArgs in the Firefox debugger this is what I came up with:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ioArgs.content.returnGeometry == true&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //modify the request with a preventCache option before it is sent to the server
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // so the feature layer is not cached in the browser
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; esri.setRequestPreCallback(function (ioArgs) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ioArgs.url.indexOf("FeatureServer") &amp;gt; -1 &amp;amp;&amp;amp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.content.returnGeometry == true) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ioArgs.preventCache = true;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ioArgs;

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(e.toString());
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ioArgs;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Worked in IE9 and Firefox18.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457112#M42196</guid>
      <dc:creator>DimitarKolev</dc:creator>
      <dc:date>2021-12-11T20:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Disable Caching on FeatureLayer.refresh()</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457113#M42197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I had this problem for a very long time, but it looks that managed to find the solutions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is only if you use proxy page.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just add&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setHeader("Cache-Control","no-cache");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setHeader("Pragma","no-cache");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; response.setDateHeader ("Expires", 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;to your proxy.jsp and all the requests will not be cached.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using JSAPI 2.8 and server 10.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Apr 2013 07:56:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/disable-caching-on-featurelayer-refresh/m-p/457113#M42197</guid>
      <dc:creator>Mindaugas_ižas</dc:creator>
      <dc:date>2013-04-03T07:56:37Z</dc:date>
    </item>
  </channel>
</rss>

