CB-6928: Open output stream only if it's necessary.
CB-6928: Implements NOT_MODIFIED check downloading resources.