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 Answers 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()
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.
or alternatively refer to caching resources in the Geoserver manual:
https://docs.geoserver.org/stable/en/user/geowebcache/webadmin/defaults.html
Explore related questions
See similar questions with these tags.
setInterval
if necessary to update it, e.g.'TIMESTAMP': new Date().getTime()