In an effort to try to prevent myself from burning through hundreds of GB of bandwidth every month and ultimately switch back to my prior Cloudflare and DigitalOcean setup, I’ve started experimenting with custom cache headers in my netlify.toml file:
[[headers]]
for = "/*.css"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.js"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.svg"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.png"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.jpg"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.gif"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.ttf"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.otf"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.woff"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
[[headers]]
for = "/*.woff2"
[headers.values]
Cache-Control = "public, s-max-age=2592000"
Beyond HTML and XML, my site assets don’t change very frequently so rather than invalidating the cache after every request, I’d rather just serve from the cache. My CSS and JavaScript have bundle identifiers, so in the event I need to roll my website back, the HTML should point at the old bundles.
I’m going to let this sit for a few days and see if the bandwidth usage slows down. In the mean time, can @fool or @laura please chime in? Current events will have me paying significantly more than I was previously and I’d like to come up with solutions to prevent this.
Thanks,