cache thumbnails in the database