Correct way to set Expires on Caddy 2?

A more optimal variant (avoiding regex in favour of substring checks) would be as follows:

@static {
  file
  path *.ico *.css *.js *.gif *.jpg *.jpeg *.png *.svg *.woff
}
header @static Cache-Control max-age=5184000

Note especially that I have added the file matcher to @static - this ensures the file exists on disk before Caddy will send the Cache-Control header. No point caching a 404!

7 Likes