fix cache invalidation ; fix attachment creation in attach_doc