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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The ArcGIS Javascript API has a nice refresh interface for ArcGISDynamicMapServiceLayer:

    var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("");

    if (dynamicMapServiceLayer.disableClientCaching) {
        aspect.after(dynamicMapServiceLayer, "onUpdateEnd", function () {
            $.delay(15000, "UpdateDynamicLayer", function () {

But this is not generalized across the other layer types. Anyone have a solution for refreshing layers of any type?

share|improve this question
Can you outline a scenario where you'd need to refresh a tiled or feature layer? Would removing a layer then re-adding it suffice? – Stephen Lead Aug 30 '12 at 5:01
The code below does remove and re-add it and it does suffice to some's impossible to clone a layer so you need the constructor and it's not nearly as elegant as layer.refresh(). Regarding a scenario...updating weather radar. Not interested in tiles but in WMS. – ca0v Aug 30 '12 at 13:33
Cross-posted this to the ESRI forum at – ca0v Aug 30 '12 at 13:55
up vote 1 down vote accepted

Replace getImageUrl and modify the url before passing it to the callback:

    layer = new esri.layers.WMSLayer("", {
        visibleLayers: ['1', '2']

    function extendLayer(layer)
        var getImageUrl, tick;

        tick = 0;
        getImageUrl = layer.getImageUrl;

        layer.setDisableClientCaching = layer.setDisableClientCaching || function(disable)
            if (disable)
                layer.getImageUrl = function (extent, width, height, callback) {
                    var result =, extent, width, height, function (url) {
              , url + "&_c=" + tick++);
                    return result;
                layer.getImageUrl = getImageUrl;
        return layer;

    extendLayer ( layer ).setDisableClientCaching ( true );

    setInterval(function () {
    }, 5000);

share|improve this answer

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.