0

I have a web app with Maps on several pages using OpenLayers as a client and GeoServer as a backend. The layers are WMS tiles.

On one page, if you visit it, and go to several zoom levels (of the WMS Tile layer),

and then say go into GeoServer and change the styling on that layer.

Then come back to this page, the style will not change for these zoom levels, and watching the browser requests, requests do not occurr at previously visited zoom levels.

I have Response Cached Headers OFF, Tile Caching OFF on the Layer.

Why is the request not being sent? Note the web pages are asp.net, requested via AJAX.

  • Are you using WMS or WMTS? which browser are you using? – Ian Turton Sep 19 '18 at 7:19
  • @IanTurton - WMS and I have tested in IE, Chrome, and Firefox. Interestingly, I use the same map "control" (javascript class) on several pages and only have this behavior on one, the only difference being the initial zoom level. – user210757 Sep 19 '18 at 14:21
2

Try adding a dummy timestamp parameter to the WMS call in OpenLayers which should be ignored by the server but will stop browsers caching tiles, for example:

params: {
    'VERSION': '1.1.1',
    'LAYERS': 'osm_auto:all',
    'TIMESTAMP': new Date().getTime()
},

If you need to reset while a page is loaded use code such as

layers[0].getSource().updateParams({'TIMESTAMP': new Date().getTime()});

  • I'm already doing this with parameter "TIME" - would this be any different? – user210757 Sep 19 '18 at 14:06
  • My param was 'TIME' and I refresh with Date.now(). I was initializing to undefined however, initializing to Date.now() seems to have resolved this issue for me. – user210757 Sep 19 '18 at 14:28
  • 1
    Any parameter set to the current time should stop browsers using cache, but TIME is a WMS keyword used for selecting historical data, so best to use a different name in case it confuses the server. – Mike Sep 19 '18 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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