From e30711c527afab46c9d7e76ccf037638ddf7fc68 Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Dec 2022 09:43:15 -0800 Subject: [PATCH 1/3] Prevent caching when ENABLE_CACHE = false. Enable Caching when ENABLE_CACHE = true. --- master_deploy.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/master_deploy.sh b/master_deploy.sh index 7f2f405..a5ed8db 100755 --- a/master_deploy.sh +++ b/master_deploy.sh @@ -649,10 +649,13 @@ deploy_s3bucket() { cat /etc/mime.types | grep -i map cat /etc/mime.types | grep -i ttf if [ "$CFCACHE" = "true" ]; then - S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0" - echo "*** Deploying with Cloudfront Cache disabled ***" + # caching is enabled, so set the cache control's max age + S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400" + echo "*** Deploying with Cloudfront Cache enabled ***" else - S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400" + # caching is disabled, so set the cache control to never cache + S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0" + echo "*** Deploying with Cloudfront Cache disabled ***" fi S3_OPTIONS="--exclude '*.txt' --exclude '*.js' --exclude '*.css'" From d3a33f41033e59e2742180f1d5dd989bb9deef2e Mon Sep 17 00:00:00 2001 From: Brooke Date: Tue, 6 Dec 2022 09:51:18 -0800 Subject: [PATCH 2/3] fix tabbing --- master_deploy.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/master_deploy.sh b/master_deploy.sh index a5ed8db..4909a0f 100755 --- a/master_deploy.sh +++ b/master_deploy.sh @@ -649,12 +649,12 @@ deploy_s3bucket() { cat /etc/mime.types | grep -i map cat /etc/mime.types | grep -i ttf if [ "$CFCACHE" = "true" ]; then - # caching is enabled, so set the cache control's max age - S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400" + # caching is enabled, so set the cache control's max age + S3_CACHE_OPTIONS="--cache-control max-age=0,s-maxage=86400" echo "*** Deploying with Cloudfront Cache enabled ***" else - # caching is disabled, so set the cache control to never cache - S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0" + # caching is disabled, so set the cache control to never cache + S3_CACHE_OPTIONS="--cache-control private,no-store,no-cache,must-revalidate,max-age=0" echo "*** Deploying with Cloudfront Cache disabled ***" fi From 3236ec06653f696a360a3180c99f36c0447a5d2a Mon Sep 17 00:00:00 2001 From: Gunasekar-K Date: Wed, 7 Dec 2022 11:00:15 +0530 Subject: [PATCH 3/3] Added fix to invalidate cache, if cloundfront it provided without any condition Added fix to invalidate cache, if cloundfront it provided without any condition --- master_deploy.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/master_deploy.sh b/master_deploy.sh index 4909a0f..0a94902 100755 --- a/master_deploy.sh +++ b/master_deploy.sh @@ -724,7 +724,7 @@ check_invalidation_status() { invalidate_cf_cache() { - if [ "$CFCACHE" = "true" ]; then + #if [ "$CFCACHE" = "true" ]; then if [ -z $AWS_CLOUD_FRONT_ID ]; then echo "Based on header applicaiton has invalidated" echo "Skipped which is based on AWS cloudfront ID.Kindly raise request to configure cloud front ID in deployment configuration" @@ -733,7 +733,7 @@ invalidate_cf_cache() INVALIDATE_ID=`aws cloudfront create-invalidation --distribution-id $AWS_CLOUD_FRONT_ID --paths '/*' | $JQ '.Invalidation.Id'` check_invalidation_status "$INVALIDATE_ID" fi - fi + #fi } download_envfile()