mirror of
https://github.com/aljazceru/njump.git
synced 2026-01-31 11:44:34 +01:00
add cache headers.
This commit is contained in:
2
image.go
2
image.go
@@ -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)
|
||||
|
||||
1
proxy.go
1
proxy.go
@@ -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)
|
||||
|
||||
@@ -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/") {
|
||||
|
||||
Reference in New Issue
Block a user