Amazon S3 and Cloudfront cache, how to clear cache or synchronize their cache

后端 未结 9 999
死守一世寂寞
死守一世寂寞 2021-01-30 05:59

I have a cron job that runs every 10 minutes and updates the content-type and x-amz-meta. But since yesterday it seems like after the cron job run, Amazon is not picking up the

9条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 06:50

    If you're looking for a minimal solution that invalidates the cache, this edited version of Dr Manhattan's solution should be sufficient. Note that I'm specifying the root / directory to indicate I want the whole site refreshed.

    export AWS_ACCESS_KEY_ID=
    export AWS_SECRET_ACCESS_KEY=
    export AWS_DEFAULT_REGION=eu-west-1
    
    echo "Invalidating cloudfrond distribution to get fresh cache"
    aws cloudfront create-invalidation --distribution-id= --paths / --profile=
    

    Region Codes can be found here

    You'll also need to create a profile using the aws cli. Use the aws configure --profile option. Below is an example snippet from Amazon.

    $ aws configure --profile user2
    AWS Access Key ID [None]: AKIAI44QH8DHBEXAMPLE
    AWS Secret Access Key [None]: je7MtGbClwBF/2Zp9Utk/h3yCo8nvbEXAMPLEKEY
    Default region name [None]: us-east-1
    Default output format [None]: text
    

提交回复
热议问题