Skip to content

Commit

Permalink
Cache static content
Browse files Browse the repository at this point in the history
  • Loading branch information
s-gv committed Sep 7, 2021
1 parent 8de4866 commit 00ef574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

<title>{{ block "title" . }}Orange Forum{{ end }}</title>

<link rel="shortcut icon" href="{{ .BasePath }}static/favicon.png">
<link rel="stylesheet" href="{{ .BasePath }}static/orangeforum.css?v=100">
<link rel="shortcut icon" href="{{ .BasePath }}static/favicon.png?v=223">
<link rel="stylesheet" href="{{ .BasePath }}static/orangeforum.css?v=223">
</head>
<body>
<div id="topbar">
Expand Down Expand Up @@ -43,6 +43,6 @@
{{ block "body" . }}
{{ end }}
</div>
<script src="{{ .BasePath }}static/orangeforum.js?v=100"></script>
<script src="{{ .BasePath }}static/orangeforum.js?v=223"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions views/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,24 @@ import (

func getCSS(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/css")
w.Header().Set("Cache-Control", "max-age=31536000")
w.Write([]byte(templates.CSSStr))
}

func getJS(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/javascript")
w.Header().Set("Cache-Control", "max-age=31536000")
w.Write([]byte(templates.JSStr))
}

func getIcon(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/png")
w.Header().Set("Cache-Control", "max-age=31536000")
w.Write([]byte(templates.IconStr))
}

func getLogo(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "image/png")
w.Header().Set("Cache-Control", "max-age=31536000")
w.Write([]byte(templates.LogoStr))
}

0 comments on commit 00ef574

Please sign in to comment.