mirror of
https://github.com/vbatts/imgsrv.git
synced 2024-11-23 16:45:39 +00:00
adding javascript loading to the page. moar caching headers.
This commit is contained in:
parent
f54091db6e
commit
06185db73b
2 changed files with 16 additions and 5 deletions
|
@ -14,6 +14,11 @@ var headTemplateHTML = `
|
|||
<html>
|
||||
<head>
|
||||
<link href="/assets/bootstrap.css" media="screen" rel="stylesheet" type="text/css" />
|
||||
|
||||
<script src="/assets/jquery.js" type="text/javascript" ></script>
|
||||
<script src="/assets/jqud.js" type="text/javascript" ></script>
|
||||
<script src="/assets/bootstrap.js" type="text/javascript" ></script>
|
||||
|
||||
<title>{{.title}}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
16
server.go
16
server.go
|
@ -719,20 +719,26 @@ func routeAssets(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
w.Header().Set("Cache-Control", "max-age=315360000")
|
||||
w.Header().Set("Cache-Control", "max-age=315360000, public")
|
||||
w.Header().Set("Expires", time.Now().AddDate(1, 0, 0).UTC().Format(time.RFC1123))
|
||||
|
||||
switch path {
|
||||
case "bootstrap.css":
|
||||
fmt.Fprintf(w, "%s", assets.BootstrapCss())
|
||||
w.Header().Set("Content-Type", "text/css")
|
||||
fmt.Fprintf(w, "%s", assets.BootstrapCss())
|
||||
case "bootstrap.js":
|
||||
w.Header().Set("Content-Type", "text/javascript")
|
||||
fmt.Fprintf(w, "%s", assets.BootstrapJs())
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
case "jquery.js":
|
||||
w.Header().Set("Content-Type", "text/javascript")
|
||||
fmt.Fprintf(w, "%s", assets.JqueryJs())
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
case "jqud.js":
|
||||
w.Header().Set("Content-Type", "text/javascript")
|
||||
fmt.Fprintf(w, "%s", assets.TagCloudJs())
|
||||
w.Header().Set("Content-Type", "application/javascript")
|
||||
default:
|
||||
httplog.LogRequest(r, 404)
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
httplog.LogRequest(r, 200) // if we make it this far, then log success
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue