amazon web services - How can I deploy a new cloudfront s3 version without a small period of unavailability? -
i utilizing aws cloudfront s3 origin. i'm using webpack plugin cache-bust using chunked hash file names of static files excluding index.html, invalidate using cloudfront feature upon each new release.
i plan on using jenkins build run aws s3 sync ./dist s3://bucket-name/dist --recursive --delete
swap out new chunked files necessary. overwrite index.html
file use new chunked reference. during few seconds (max) takes swap out old files new, possible user make request website region in cloudfront has not cached resources, @ point they'll unavailable because have deleted them.
i not find information avoiding edge case.
yes, can happen person near different edge location experience missing files. solve this, need change approach of doing new deployments since cache busting , time unpredictable @ request-response level. 1 commonly used pattern keep different directories(paths) each new deployment in s3 follows.
for release v1.0 /dist/v1.0/js/* /dist/v1.0/css/* /dist/index.html <- index.html v1.0 release has reference js & css in /dist/v1.0 path release v1.1 /dist/v1.1/js/* /dist/v1.1/css/* /dist/index.html <- index.html v1.1 release has reference js & css in /dist/v1.1 path
after each deployment, user receive either old version(v1.0) or new version(v1.1) of index.html, still working during transition period until edge cache busted.
you can automate versioning jenkins either incrementing version or using parameterize build plugin.
this useful immutable deployments, in case of critical issue, can rollback previous deployments. apart can configure s3 lifecycle management rules archive older versions.
Comments
Post a Comment