Sign up ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I posted this on the ESRI forum a while back but got no response.

PROBLEM: GetImageUrl is called twice resulting in two trips to the server if caching is off.

QUESTION: How can this be prevented (other than turn browser caching on)?


  1. Go to any sample with a dynamic layer (e.g.
  2. Run a tool like fiddler2 to monitor IP traffic
  3. Resize the browser
  4. Notice that two identical requests are sent:

A single call to map._resize results in getImageUrl being called twice (once for the resize and once for the change of extent).

I am looking for a way to eliminate the redundant call with a minimal amount of coding.

share|improve this question
This isn't an answer, hence the reason I'm posting a comment, but why can't you use browser caching? – Derek Swingley Feb 28 '12 at 16:41
I agree that in practice it's not going to be an issue but on our dev box when profiling it looks bad and it's an issue ESRI may wish to address if a simple workaround is found. It may not be a simple fix without access to the ESRI source. – ca0v Feb 28 '12 at 16:54

1 Answer 1

The resize event gets fired before the extent-change. One hack is to "disable" the map's extent-change just before the layer's getImageUrl is called.

I have tried the below snippet on this sample, which uses an ArcGISImageServiceLayer:

window.onExtentChangeFunction = lang.clone(map.onExtentChange);

aspect.before(imageServiceLayer, "getImageUrl", function(){
      //remove extentChange handler for 50ms;
      map.onExtentChange = function(){};
      setTimeout(function() {
        map.onExtentChange = lang.clone(window.onExtentChangeFunction);
      }, 0);
share|improve this answer
does the timeout value actually have to be 50? What happens if you use 0 to simply force it to fire after a repaint? – tomfumb Dec 29 '14 at 16:30
Good point @tomfumb. timeout of 0 works well. – Aamir Suleman Dec 29 '14 at 17:16
OK then I suggest you update the answer to use 0 - this shows that the length of the delay isn't what fixes the problem, the important part is pushing the handler function to the bottom of the stack. Using 0 in combination with a simple comment should make the next developer that works with the code a little less nervous. – tomfumb Dec 29 '14 at 17:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.