mirror of
https://github.com/muety/wakapi.git
synced 2025-12-05 22:20:24 -08:00
chore: use more aggressive cache busting at dev time (see #795)
This commit is contained in:
@@ -76,6 +76,8 @@ const colorsFile = "data/colors.json"
|
||||
|
||||
var leaderboardScopes = []string{"24_hours", "week", "month", "year", "7_days", "14_days", "30_days", "6_months", "12_months", "all_time"}
|
||||
|
||||
var appStartTime = time.Now()
|
||||
|
||||
var cfg *Config
|
||||
var env string
|
||||
|
||||
@@ -207,6 +209,10 @@ type Config struct {
|
||||
Mail mailConfig
|
||||
}
|
||||
|
||||
func (c *Config) AppStartTimestamp() string {
|
||||
return fmt.Sprintf("%d", appStartTime.Unix())
|
||||
}
|
||||
|
||||
func (c *Config) CreateCookie(name, value string) *http.Cookie {
|
||||
return c.createCookie(name, value, c.Server.BasePath, c.Security.CookieMaxAgeSec)
|
||||
}
|
||||
|
||||
@@ -52,6 +52,13 @@ func DefaultTemplateFuncs() template.FuncMap {
|
||||
"getDbType": func() string {
|
||||
return strings.ToLower(config.Get().Db.Type)
|
||||
},
|
||||
"getCacheBuster": func() string {
|
||||
cfg := config.Get()
|
||||
if v := config.Get().Version; v != "dev" {
|
||||
return v
|
||||
}
|
||||
return cfg.AppStartTimestamp()
|
||||
},
|
||||
"htmlSafe": func(html string) template.HTML {
|
||||
return template.HTML(html)
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script src="assets/vendor/iconify.basic.min.js"></script>
|
||||
<script src="assets/vendor/seedrandom.min.js"></script>
|
||||
<script src="assets/vendor/chart.min.js"></script>
|
||||
<script src="assets/js/icons.dist.js?v={{ getVersion }}"></script>
|
||||
<script src="assets/js/base.js?v={{ getVersion }}"></script>
|
||||
<script src="assets/js/icons.dist.js?v={{ getCacheBuster }}"></script>
|
||||
<script src="assets/js/base.js?v={{ getCacheBuster }}"></script>
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon-16x16.png">
|
||||
<link rel="manifest" href="assets/site.webmanifest">
|
||||
<link href="assets/vendor/source-sans-3.css" rel="stylesheet">
|
||||
<link href="assets/css/app.dist.css?v={{ getVersion }}" rel="stylesheet">
|
||||
<link href="assets/css/app.dist.css?v={{ getCacheBuster }}" rel="stylesheet">
|
||||
<script src="assets/vendor/petite-vue.min.js" defer></script>
|
||||
</head>
|
||||
@@ -3,9 +3,9 @@
|
||||
|
||||
{{ template "head.tpl.html" . }}
|
||||
|
||||
<script src="assets/js/components/time-picker.js?v={{ getVersion }}"></script>
|
||||
<script src="assets/js/components/entity-filter.js?v={{ getVersion }}"></script>
|
||||
<script type="module" src="assets/js/components/summary.js?v={{ getVersion }}"></script>
|
||||
<script src="assets/js/components/time-picker.js?v={{ getCacheBuster }}"></script>
|
||||
<script src="assets/js/components/entity-filter.js?v={{ getCacheBuster }}"></script>
|
||||
<script type="module" src="assets/js/components/summary.js?v={{ getCacheBuster }}"></script>
|
||||
|
||||
<body class="relative bg-gray-900 text-gray-700 p-4 pt-10 flex flex-col min-h-screen max-w-screen-xl mx-auto">
|
||||
|
||||
@@ -409,7 +409,7 @@
|
||||
</script>
|
||||
<script src="assets/vendor/hammer.min.js"></script>
|
||||
<script src="assets/vendor/chartjs-plugin-zoom.min.js"></script>
|
||||
<script src="assets/js/summary.js?v={{ getVersion }}"></script>
|
||||
<script src="assets/js/summary.js?v={{ getCacheBuster }}"></script>
|
||||
{{ end }}
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user