From 1005fb973eaa2e28f8369d052e01d99fa0518444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Fri, 21 May 2021 13:57:11 -0700 Subject: [PATCH] Avoid custom stylesheet to be cached by third-party CDN If the application is hosted behind a CDN like Cloudflare, then all custom stylesheets is be the same for all users. The random query string prevent the CDN to cache this. --- template/functions.go | 4 ++++ template/templates/common/layout.html | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/template/functions.go b/template/functions.go index d705f098..a38893e0 100644 --- a/template/functions.go +++ b/template/functions.go @@ -13,6 +13,7 @@ import ( "time" "miniflux.app/config" + "miniflux.app/crypto" "miniflux.app/http/route" "miniflux.app/locale" "miniflux.app/model" @@ -87,6 +88,9 @@ func (f *funcMap) Map() template.FuncMap { iconName, )) }, + "rand": func() string { + return crypto.GenerateRandomStringHex(10) + }, // These functions are overrode at runtime after the parsing. "elapsed": func(timezone string, t time.Time) string { diff --git a/template/templates/common/layout.html b/template/templates/common/layout.html index 5b028f77..7589847c 100644 --- a/template/templates/common/layout.html +++ b/template/templates/common/layout.html @@ -36,7 +36,7 @@ {{ if and .user .user.Stylesheet }} - + {{ end }}