I have seen several posts regarding this issue so apologies but none of them have provided a solution. I cannot figure out why GeoServer is not caching the tiles requested using WMS. I am certain I have satisfied all the requirements as listed
https://docs.geoserver.org/latest/en/user/geowebcache/using.html. The data loads fine on the map but there is nothing being cached in the gwc folder. It caches fine when previewing the layer via the GeoWebCache demo page. I am also able to cache the layers beforehand and load them using the gwc endpoint using WMTS. However, caching the data in advance is not feasible, hence wishing to call WMS and allow that to cache on the fly.
Details:
- I have an ImageMosaic layer where the workspace and the layer are both named AREA35. Caching is enabled for this layer. I only display the layer on the Openlayers map at scales 1:5000, 1:2500, 1:1000 and 1:500 scale (4 zoom levels).
- Using EPSG:27700 projection. Created a grid set named EPSG:27700 that has the 4 zoom levels mentioned above and the Tile width in pixels and Tile height in pixels are both set to 256. However, I am trying to test caching just the top 2 zooms levels (1:5000 and 1:2500).
- The layer is set to use tile size 256,256 that matches the grid set dimensions.
- Tiled=true is passed.
- I only request a single layer (AREA35:AREA35).
- I request tiles of size height 256 and width 256.
- I specify the CRS to be EPSG:27700.
- WMS version set to 1.3.0.
- Tile format image/png8. This matches the Raster Layers setting in Caching Defaults page.
- Requirements: “The image requested lines up with the existing grid bounds” and “A parameter is included for which there is a corresponding Parameter Filter” – not sure how to check the first one, but I have explicitly set both coordinate systems to be EPSG:27700 in the layer and the caching grid set. Also not sure about the second requirement – I know I am not passing any of the supported parameters/filters as I have no need.
Front end code (OpenLayers 3):
let aerialLayer = new openLayers.layer.Tile({
preload: Infinity,
visible: true,
title: 'AREA35:AREA35',
source: new openLayers.source.TileWMS(({
url: 'https://<server>/geoserver/wms',
params: {
'LAYERS': 'AREA35:AREA35', 'TILED': true, 'VERSION': '1.3.0',
'FORMAT': 'image/png8', 'WIDTH': 256, 'HEIGHT': 256, 'CRS': 'EPSG:27700'
},
serverType: 'geoserver'
})),
extent: [345400, 185600, 357600, 191800]
});
map.addLayer(aerialLayer);
The map projection is also EPSG:27700 and the bounds/extent is set to the official bounds taken from spatialreference.org for EPSG:27700: [1393.0196, 13494.9764, 671196.3657, 1230275.0454]. NOTE: The caching grid set has these bounds explicitly set too, but I do not know if able to explicitly set these bounds on the layer itself in the Coordinate Reference Systems section for the declared/native SRS values.
The following is a request taken from DEV tools:
The following are screens taken from GeoServer / GeoWebCache:
Layer Settings:
UPDATE 1: Having checked DEV tool all requests made report:
MISS / no parameter filter exists for FORMAT_OPTIONS:
Therefore I added a FORMAT_OPTIONS
filter to the layer for dpi values (NOTE: I checked the requests to see what value is being passed for dpi. It obviously differs depending on the browser screen/resolution - so do I need to specify all possible dpi's?). I added the following
FORMAT_OPTIONS
and dpi values for the layer (I checked the value being passed in the request, plus the set the default to be 90 as specified in the GeoServer docs):
UPDATE 2: now I receive MISS / request does not align to grid(s) 'EPSG:27700'
Is this due to one of the following:
- I have specified the FORMAT_OPTIONS incorrectly (including the dpi values/setting)
- The fact the grid set I created for caching (EPSG:27700) uses bounds that I explicitly set from official spatialreference.org website whereas the (default) EPSG:27700 SRS that the layer uses has bounds that are not the same as the caching grid set bounds? I do not know how to change the bounds of the SRS used by the layer.