date: 2018-09-18 23:34:34 +0800 title: “http.expires”
sitename: “Caddy中文文档”
http.expires
expires允许设置相对于请求时间的过期头信息。它允许你根据与正则表达式匹配的路径设置不同的过期时间。
语法
expires {match regex duration}
- match: 路径的正则表达式以及过期时间。
match子指令可以重复多次,但只使用与路径首次匹配上的配置。
duration是按顺序排列的0y0m0d0h0i0s的组合。部件可以省略。
示例
各种资源的过期时间
expires {match some/path/.*.css$ 1y # expirescss files in some/path after one yearmatch .js$ 1m # expiresjs files after 30 daysmatch .png$ 1d # expirespng files after one daymatch .jpg$ 1h # expiresjpg files after one hourmatch .pdf$ 1i # expirespdf file after one minutematch .txt$ 1s # expirestxt files after one secondmatch .html$ 5i30s # expireshtml files after 5 minutes 30 seconds}
你可以按照你的需要指定各种粒度的过期指令。
使用第一个匹配规则。
