pgherveou / gulp-awspublish

gulp plugin to publish files to amazon s3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suggestion: delay deletion

michalc opened this issue · comments

If publishing a static website where the non-HTML resources (scripts, images etc) are versioned (with far-future expires headers), then I realise deletion of the previous resources causes a bit of a race condition

  • A client requests a HTML file from the site
  • A new version of the site, with new resources is uploaded to S3
  • The old resources are deleted
  • A client now requests the resources from the original HTML file, which are now deleted, and a 404 is returned

I suspect this can't be 100% protected against, but a delay between upload and deletion could reduce the risk of it.

I was thinking along similar lines and that S3 Object Expiration could do it. Unfortunately you can't set an object lifecycle policy just for an object. Only for a bucket and then narrow it down with prefixes or tags.

I would recommend not deleting any resource and eventually use https://github.com/sindresorhus/gulp-rev to make deployments "immutable" in some way. Anyway, I don't think it can be solve properly within the scope of this package.