Setting a custom tile size for a WMS layer in OpenLayers 3 is a bit more involved than with OpenLayers 2. It requires the use of the
ol.tilegrid.TileGrid class. This class provides some flexible control over the grid pattern that is used for sources accessing tiled image servers.
Of course, controlling the tile size of the WMS request can affect the performance. By default, the tile size is 256 x 256 pixels, but we can set this to something different. Bigger tile sizes mean fewer requests to the server but more computation time to generate a bigger image and a larger download size per image. On the contrary, smaller tile sizes mean more server requests and less time to compute smaller images. If you use the default tile sizes, then it's more likely the images will have already been cached, so it may increase performance.
In any case, it's good to know how we can make these adjustments. The source code can be found in
ch02/ch02-tile-size/. Here's what we...