I have deployed my application on AWS amplify. And I have added customHttp.yml file on root level with cache headers .But this headers are not being applied. and images inside static folder are taking very long time even image sizes are not more than 10KB .
customHeaders:
- pattern: '/build/static/media/*.{webp,jpg,jpeg,png,svg,ico}'
headers:
- key: 'Cache-Control'
value: 'public, max-age=31536000, immutable'
- pattern: '/build/images/home/*.{webp,jpg,jpeg,png,svg,ico}'
headers:
- key: 'Cache-Control'
value: 'public, max-age=31536000, immutable'
- pattern: '/build/images/sportsbook/*.{webp,jpg,jpeg,png,svg,ico}'
headers:
- key: 'Cache-Control'
value: 'public, max-age=31536000, immutable'
- pattern: '/build/static/js/*.js'
headers:
- key: 'Cache-Control'
value: 'public, max-age=31536000, immutable'
- pattern: '/build/static/css/*.css'
headers:
- key: 'Cache-Control'
value: 'public, max-age=31536000, immutable'
Have you verified that the
customHttp.ymlis being applied, by navigating to the Custom Headers settings page in AWS Amplify console?max-ageis overridden bys-maxage(for shared cache); it's possible there's ans-maxageheader specified somewhere that's overriding your value. In any case s-maxage is typically used for edge caching scenarios like yours, so I'd recommend switching to it.Failing that, how are you sure the response wasn't fulfilled by cache? Does the
Last-Modifiedresponse header always correspond to the request time?Also Amplify caps the
s-maxagevalue to 1 day; this isn't the cause of your issue but worth noting.