I have data in a PostGIS database that is being pulled into Geoserver using a PostGIS (JNDI) store. The dataset I am using is a continuous polygon grid, but the dataset itself isn't all that large. When I try to have Geoserver's GeoWebCache cache this layer, at a certain zoom level, the layer appears to only be partially complete at the time the GWC "takes a snapshot" of the data. If I zoom in or zoom out one level, the layer tiles appear correct.
The layers are stored as 4326 in PostGIS, but are served as 900913. I have tried converting the table geometry to 900913 so there wouldn't need to be any re-projection, but this has no effect on the cache tiles. I have also tried caching using 4326, but those tiles have the same incomplete layers.
The dataset has a geometry index and the table is clustered on the index.
Is there some kind of optimization I'm not thinking of that would allow GeoWebCache to cache the complete layer instead of the incomplete one?
EDIT: I tried changing the styling to the default "polygon" style, and the layer appears correctly when cached. So it doesn't appear to be an issue with the geometry, it is instead an issue with the styling. I tried making the styling as simple as possible by not needing Geoserver to do any searching for values between X and Y, but instead replacing bins with integers. I also applied an index to the column being used for styling. So all Geoserver really needs to do is style bin_val = 1 blue, bin_val = 2 red, and so forth, but even that isn't returning a complete cached layer.
For example, this is what the cache looks like at zoom level 5:
And this is zoom level 4, notice the Alaskan data is only the outermost grid polygons, while the more inshore ones are not visible:
Geoserver version 2.4.5