serverless / serverless-client-s3

A plugin to deploy front-end assets to S3 via the Serverless Framework
http://www.serverless.com
171 stars 61 forks source link

Add Cache-Control capabilities to s3 deployment #49

Closed andresbravog closed 6 years ago

andresbravog commented 7 years ago

Cache-Control headers can be provided to S3 elements in order to allow browser and CloudFront caching

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html

In order to control this by file or for all of them I've created the possibility to give that custom param

Now we can do something like

{
    "name": "yourProject",
    "custom": { 
      "client": {   
      "bucketName": "yourBucketName",
      "CacheControl": {
        "value": "max-age=300, s-maxage=300",
        "regex": ".*\\.(gif|jpe?g|png|js|svg|css)$"
      }
    },
    "plugins": [
     "serverless-client-s3"
    ]
}
andresbravog commented 6 years ago

ping