add cache headers.

This commit is contained in:
fiatjaf
2023-05-11 17:41:49 -03:00
parent 119b523112
commit d144f5d14d
3 changed files with 4 additions and 0 deletions

View File

@@ -32,6 +32,8 @@ func generate(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "image/png")
w.Header().Set("Cache-Control", "max-age=604800")
if err := png.Encode(w, img); err != nil {
log.Printf("error encoding image: %s", err)
http.Error(w, "error encoding image!", 500)

View File

@@ -9,6 +9,7 @@ import (
func proxy(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
w.Header().Set("Cache-Control", "max-age=604800")
src := r.URL.Query().Get("src")
urlParsed, err := url.Parse(src)

View File

@@ -21,6 +21,7 @@ var tmpl = template.Must(template.New("event").Parse(eventHTML))
func render(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
w.Header().Set("Content-Type", "text/html")
w.Header().Set("Cache-Control", "max-age=604800")
code := r.URL.Path[1:]
if strings.HasPrefix(code, "e/") {