Don't query for objects in a response when we know the count is 0.

When building a paginated webapi response, we would always perform a
query for the count and a query for the objects. The latter query is
pointless if the count is 0, so only do it if we know there are objects
to fetch.
Cache calculated values when we know they won't change.

We frequently get the name and name_plural properties of an API
resource. In the case where a resource doesn't explicitly set them, we
calculate them, and we do this every time it's accessed, even though
it'll never change. Instead, cache these values and only calculate them
once.
Merge branch 'release-0.7.x'