no-cache for templates, tune map position
This commit is contained in:
parent
992fb3d4f1
commit
6179b81f71
30
main.go
30
main.go
|
|
@ -9,6 +9,24 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var epoch = time.Unix(0, 0).Format(time.RFC1123)
|
||||||
|
|
||||||
|
var noCacheHeaders = map[string]string{
|
||||||
|
"Expires": epoch,
|
||||||
|
"Cache-Control": "no-cache, private, max-age=0",
|
||||||
|
"Pragma": "no-cache",
|
||||||
|
"X-Accel-Expires": "0",
|
||||||
|
}
|
||||||
|
|
||||||
|
var etagHeaders = []string{
|
||||||
|
"ETag",
|
||||||
|
"If-Modified-Since",
|
||||||
|
"If-Match",
|
||||||
|
"If-None-Match",
|
||||||
|
"If-Range",
|
||||||
|
"If-Unmodified-Since",
|
||||||
|
}
|
||||||
|
|
||||||
func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
||||||
logit("Called URL: " + r.URL.Path)
|
logit("Called URL: " + r.URL.Path)
|
||||||
// wennn kein File angegeben ist: index.html
|
// wennn kein File angegeben ist: index.html
|
||||||
|
|
@ -77,6 +95,18 @@ func serveTemplate(w http.ResponseWriter, r *http.Request) {
|
||||||
// because of caching, we need to set the Last-Modified header
|
// because of caching, we need to set the Last-Modified header
|
||||||
w.Header().Set("Last-Modified", time.Now().Format(http.TimeFormat))
|
w.Header().Set("Last-Modified", time.Now().Format(http.TimeFormat))
|
||||||
|
|
||||||
|
// Delete any ETag headers that may have been set
|
||||||
|
for _, v := range etagHeaders {
|
||||||
|
if r.Header.Get(v) != "" {
|
||||||
|
r.Header.Del(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set our NoCache headers
|
||||||
|
for k, v := range noCacheHeaders {
|
||||||
|
w.Header().Set(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
if err := tmpl.ExecuteTemplate(w, "layout", &data); err != nil {
|
if err := tmpl.ExecuteTemplate(w, "layout", &data); err != nil {
|
||||||
logit(err.Error())
|
logit(err.Error())
|
||||||
http.Error(w, http.StatusText(500), 500)
|
http.Error(w, http.StatusText(500), 500)
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"
|
||||||
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
|
||||||
crossorigin=""></script>
|
crossorigin=""></script>
|
||||||
<script type="text/javascript" src="/static/js/Map.SelectArea.min.js"></script>
|
<script src="/static/js/Map.SelectArea.min.js"></script>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{define "body_content"}}
|
{{define "body_content"}}
|
||||||
{{ if ne .UserName "" }}
|
{{ if ne .UserName "" }}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,11 @@ html,body {
|
||||||
}
|
}
|
||||||
|
|
||||||
.section,.container {
|
.section,.container {
|
||||||
height: 85%;
|
height: calc(100% - 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.daterangepicker {
|
||||||
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
|
|
@ -80,7 +84,7 @@ input:focus,
|
||||||
}
|
}
|
||||||
|
|
||||||
.mapbig {
|
.mapbig {
|
||||||
height: 100%;
|
height: calc(100% - 100px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.slidecontainer {
|
.slidecontainer {
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ function refreshDatapoints(deveui, start, stop) {
|
||||||
$('#datetimeslider').hide();
|
$('#datetimeslider').hide();
|
||||||
$('#chart').html(`<article class="message is-danger">
|
$('#chart').html(`<article class="message is-danger">
|
||||||
<div class="message-body">
|
<div class="message-body">
|
||||||
Keine Messpunkte für diese Zeitperiode
|
Keine GPS-Messpunkte für diese Zeitperiode
|
||||||
</div>
|
</div>
|
||||||
</article>`);
|
</article>`);
|
||||||
$('#chart').show();
|
$('#chart').show();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue