Cache total pages of a document in the db.