# How to update WMS layer?

**URL:** <https://community.cesium.com/t/how-to-update-wms-layer/7454>\
**Category:** CesiumJS\
**Created:** [September 18, 2018, 1:53pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454 "2018-09-18T13:53:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![google](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/google/32/3627_2.png) [@google](https://community.cesium.com/u/google)\
**Post date:** [September 18, 2018, 1:53pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/1 "2018-09-18T13:53:43Z")

</div>

I'm currently working on an app displaying data from a WMS. The data of the source is frequently updated, and therefore the layer needs to be updated as well. However, the viewport only issues new requests when the map is either zoomed or panned.

What is the best way to force the viewport to re-request and redraw the WMS layer?

BTW: I'm currently using Cesium 1.49.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [September 19, 2018, 11:36am UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/2 "2018-09-19T11:36:06Z")

</div>

There is a time property for WMTS that you can use for that:

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Web%20Map%20Tile%20Service%20with%20Time.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

I don’t think it’s implemented for WMS, but I believe it uses TimeDynamicImagery under the hood, so you could look into that:

[https://cesiumjs.org/Cesium/Build/Documentation/TimeDynamicImagery.html](https://cesiumjs.org/Cesium/Build/Documentation/TimeDynamicImagery.html)

I was going to suggest you could try implementing it yourself but it looks like there’s an open pull request for it! [https://github.com/AnalyticalGraphicsInc/cesium/pull/6348](https://github.com/AnalyticalGraphicsInc/cesium/pull/6348)

You could use the code from there, or wait until it’s merged into CesiumJS.

---

<div class="post-metadata">

**Author:** ![google](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/google/32/3627_2.png) [@google](https://community.cesium.com/u/google)\
**Post date:** [November 6, 2018, 3:11pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/3 "2018-11-06T15:11:19Z")

</div>

Hi,

meanwhile the pull requests has been merged and a new version is released. I tried to implement it, but I do not really understand how it is supposed to work.

I have no time line, no time interval. I simply want the layer to reload the images say every 10 seconds, as long as the page is open.

Any hints?

---

<div class="post-metadata">

**Author:** ![google](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/google/32/3627_2.png) [@google](https://community.cesium.com/u/google)\
**Post date:** [November 6, 2018, 3:48pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/4 "2018-11-06T15:48:58Z")

</div>

Okay, I'm not one step further: the layer now reloads the data every few seconds. But the layer issues several requests for different resolutions. And even worse: The different resolutions are displayed. So on every update, the image is first replaced with some scaled, blurred image of an overview scale, aber soon afterwards the correct image appears.

Is it possible to stop this and only request the most appropriate resolution depending of the zoom level?

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [November 13, 2018, 3:31pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/5 "2018-11-13T15:31:06Z")

</div>

You should be in control of that if you’re implementing your own custom imagery provider. I can’t tell why it’s happening without seeing your implementation.

I still think it might be easier to use WMS-T that’s already implemented. Have you taken a look at this Sandcastle example to see how it works?

> **[Cesium Sandcastle](https://sandcastle.cesium.com/?src=Web%20Map%20Tile%20Service%20with%20Time.html)**
>
> The Cesium Sandcastle provides an interactive environment for testing Cesium code.

---

<div class="post-metadata">

**Author:** ![google](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/google/32/3627_2.png) [@google](https://community.cesium.com/u/google)\
**Post date:** [November 18, 2018, 11:10am UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/6 "2018-11-18T11:10:31Z")

</div>

I checked it, and this example behaves in the same way: When a reload is triggered, every zoom level from the top most level 0 up to the current zoom level is downloaded. As a result, the remote server is flooded with image requests, even if most of them will soon be thrown away by the client.

---

<div class="post-metadata">

**Author:** ![omar](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/omar/32/1999_2.png) [@omar](https://community.cesium.com/u/omar)\
**Post date:** [November 19, 2018, 4:25pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/7 "2018-11-19T16:25:48Z")

</div>

I see what you mean now. That’s definitely wasteful, and I believe this PR is working on overhauling that to make it a lot more efficient:

> <https://github.com/CesiumGS/cesium/pull/7061>

Which hopefully should be merged this month which would be a big win.

---

<div class="post-metadata">

**Author:** ![Scott\_Reynolds](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/scott_reynolds/32/2014_2.png) [@Scott\_Reynolds](https://community.cesium.com/u/Scott_Reynolds)\
**Post date:** [November 19, 2018, 8:00pm UTC](https://community.cesium.com/t/how-to-update-wms-layer/7454/8 "2018-11-19T20:00:50Z")

</div>

It sounds like the following is needed:

1. Add a “refreshPeriod” option to ImageryProvider.
2. ImageryProvider implementations would need to
3. When “refreshPeriod” is supplied, keep a list of requests associated with the current view.
4. Upon expiration of the “refreshPeriod” issue the saved list of requests.
5. Update the scene with the new images as they arrive.
6. Web Map Service must be configured to set the cache-control: max-age=“refreshPeriod” or similar.  
Scott
