In Geoserver I have a layer based on SQL view. I enabled WMS direct integration in GeoWebcache and I enabled caching in layer.
In Google Maps javascript API I add a layer in this way. Layer is projected, but caching not happens:
var wmsLayer =
new google.maps.ImageMapType({
getTileUrl: function (coord, zoom) {
var s = Math.pow(2, zoom);
var twidth = 256;
var theight = 256;
//define boundingbox
var gBl = cmap.getProjection().fromPointToLatLng(
new google.maps.Point(coord.x * twidth / s, (coord.y + 1) * theight / s)); //zuidwest coördinaat
var gTr = cmap.getProjection().fromPointToLatLng(
new google.maps.Point((coord.x + 1) * twidth / s, coord.y * theight / s)); //noordoost coördinaat
var bbox = gBl.lng() + "," + gBl.lat() + "," + gTr.lng() + "," + gTr.lat();
//basics WMS URL
var url = "http://geoserver.xxx.be/geoserver/rcs/wms?";
url += "&service=WMS";
url += "&version=1.1.0";
url += "&request=GetMap";
url += "&layers=rcs:rcs-sql-server-source-with-parameters-public";
url += "&styles=";
url += "&format=image/png";
url += "&TRANSPARENT=TRUE";
url += "&srs=EPSG:4326";
url += "&bbox=" + bbox;
url += "&width=256";
url += "&height=256";
url += "&customheader=" + new Date().getTime();
url += "&viewparams=kind:bike;groupid:1";
url += "&tiled=true";
return url;
},
tileSize: new google.maps.Size(256, 256),
opacity: 0.85,
isPng: true
});