1

I am making a weather application. It is almost finished now, but I just have one problem left. I want a WMS-layer to automatically reload every few seconds. I thought I had the solution, but it seems that it doens't quite work. Below (some of) my code.

It seems to redraw the WMS, but not with changed data. Only when the datetime or weathertype CHANGES, then the WMS-gets new data and that is shown on the map. But I want it to keep reloading and show the new data for that datetime. (Because the datetime only changes once in a while, but the data keeps rolling in.)

I hope I made my question clear.

I searched and found some solutions, but they didn't work for me. Besides most solutions I found were for OL2 or OL3 and I am working with OL5.

Please help me.

2
  • 2
    Adding a dummy parameter (if the name isn't recognised by the server it should ignore it) to the WMS set to the current datetime in milliseconds should force a reload and override browser caching. You could use a javasript setInterval if necessary to update it, e.g. 'TIMESTAMP': new Date().getTime()
    – Mike
    Jan 24, 2019 at 11:57
  • 1
    @Mike You should put your comment as an answer.
    – TomazicM
    Jan 24, 2019 at 20:47

2 Answers 2

1

Adding a dummy parameter (if the name isn't recognised by the server it should ignore it) to the WMS set to the current datetime in milliseconds should force a reload and override browser caching. You could use a javasript setInterval if necessary to update it, e.g. 'TIMESTAMP': new Date().getTime()

1

If it is your own WMS server, just make sure your GetMap responses are not cacheable by setting the appropriate headers. (eg. cache-control: no-cache)

You may refer to the below page for further reading if you wish to.

https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching

or alternatively refer to caching resources in the Geoserver manual:

https://docs.geoserver.org/stable/en/user/geowebcache/webadmin/defaults.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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