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.

asked Jan 24, 2019 at 11:08
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() Commented Jan 24, 2019 at 11:57
  • 1
    @Mike You should put your comment as an answer. Commented 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()

answered Jan 24, 2019 at 21:24
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

answered Jan 25, 2019 at 10:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.