[GIS] Caching / Preloading data for use with WMS queries

cachegeoserveropenlayers-2postgis

Hoping someone can help me with this issue. I've got a map implemented in my web application using OpenLayers that makes WMS queries to GeoServer that in turn queries a Postgres (PostGIS) database to produce WMS tiles. It also makes use of WMS GetFeatureInfo to get information about features being moused over.

Because of the amount of data that is being queried in the initial load for the tiles can take anywhere between 1-10+ minutes depending on the data that is being queried (query can be adjusted by date/time ranges and a few other properties), which is acceptable because it's a lot of data. But I've got a couple of performance related issues that I'm trying to get around.

  1. Every time the zoom level is changed the database has to be re-queried. Is there a way the data can be cached so that it doesn’t have to be re-queried for each change in zoom level? The data doesn’t change depending on zoom level so the query being run is returning the exact same result each time.
  2. When a user mouses over a feature, a GetFeatureInfo request is made and a popup is shown over the map detailing that feature. It once again has to run the whole query again and then it narrows it down to the feature that has been moused over.

Previously before changing to using WMS we generated a single KML file from the data we got from our database query and then this would be used for loading the map at all zoom levels and getting the feature info. We had to change from this approach to deal with bigger and more complex polygons.

So simply, is there anyway to get GeoServer to use a cache result of the query data or is there any way I could perhaps generate the KML file how I was before but then pass it to GeoServer to render it as WMS tiles?

Would much appreciate any input on the matter or any suggestions to get around the problems I've stated.

Best Answer

Given that you are requesting WMS tiles, you can use a cache service like WMS-C (WMS Cached), Tile Map Service (TMS) or Web Map Tile Service (WMTS); the latter is an OGC standard. There are several implementations of these standards; to mention some, there are GeoWebCache, TileCache or MapProxy.

Because you are using GeoServer, I think that the best solution in your case would be GeoWebCache, that has a very good integration with GeoServer. Among the standards mentioned before, perhaps WMTS is the one that suits your needs the most, because WMTS can cache the results of GetFeatureInfo requests. Currently GeoWebCache 'fully implements WMTS using KVP'.

Related Question