[GIS] GeoWebCache OpenLayers WMS request structure

geocachinggeoserveropenlayers-2wms

I'm developing a GIS app that makes use of GeoServer and GeoWebCache for serving requests, and OpenLayers for frontend. WMS requests to the GeoServer are served with no issues. But when I make a request through GeoWebCache, nothing is returned to the client. I've enabled Direct WMS Integration in GeoWebCache configuration. I'm using GeoWebCache integrated in GeoServer. My request is as shown below:

var wmslayer = new OpenLayers.Layer.WMS(
   "Kenya Administrative Boundaries",
   "http://localhost:8081/geoserver/gwc/service/wms?", 
   {layers: 'kenya_admin', format:'image/png', transparent: true},
   {opacity: 1.0, isBaseLayer: false, visibility: true}
);
map.addLayer(wmsLayer);

But the layer is not loaded. Any advice on what I may be doing wrong. Thanks in advance.

Best Answer

My understanding of Geoserver's Geowebcache documentation is that if you enable Direct WMS Integration, you can simply point your request to the regular wms service, include "TILED=true" and Geoserver handles the rest. I.e, all you have to do is change your request to:

var wmslayer = new OpenLayers.Layer.WMS(
   "Kenya Administrative Boundaries",
   "http://localhost:8081/geoserver/wms?", 
   {layers: 'kenya_admin', format:'image/png', transparent: true, TILED: 'true'},
   {opacity: 1.0, isBaseLayer: false, visibility: true}
);

I've done that with my OpenLayers site and it works... Cheers M