skyfaller
(Nelson Pavlosky)
January 31, 2020, 9:03pm
1
1. My Caddy version (caddy -version
):
v2.0.0-beta.13 h1:QL0JAepFvLVtOatABqniuDRQ4HmtvWuuSWZW24qVVtk=
3. The problem I’m having:
I want to make sure static resources are cached in users’ browsers for a year or more, as recommended by Google: Serve static assets with an efficient cache policy
I used to accomplish this, I believe correctly, by using https://caddyserver.com/v1/docs/http.expires in Caddy V1.
How do I do this in Caddy V2? Or is it not implemented yet?
Mohammed90
(Mohammed Al Sahaf)
January 31, 2020, 9:49pm
2
Welcome around, Nelson! You can use the headers
handler to set the value of Cache-Control
headers. So you should have something like this in your array of handle
:
{
"handler": "headers",
"response": {
"set": {
"Cache-Control": [
"max-age=31536000"
]
}
}
}
And depending on your directory structure, you’d use either the path
or path_regexp
matchers .
3 Likes
system
(system)
Closed
April 30, 2020, 9:49pm
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.