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.
This commit is contained in:
Frédéric Guillot 2021-05-21 13:57:11 -07:00 committed by fguillot
parent 75ac58abdf
commit 1005fb973e
2 changed files with 5 additions and 1 deletions

View file

@ -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 {

View file

@ -36,7 +36,7 @@
<meta name="theme-color" content="{{ theme_color .theme }}">
<link rel="stylesheet" type="text/css" href="{{ route "stylesheet" "name" .theme }}?{{ .theme_checksum }}">
{{ if and .user .user.Stylesheet }}
<link rel="stylesheet" type="text/css" href="{{ route "stylesheet" "name" "custom_css" }}">
<link rel="stylesheet" type="text/css" href="{{ route "stylesheet" "name" "custom_css" }}?{{ rand }}">
{{ end }}
<script type="text/javascript" src="{{ route "javascript" "name" "app" }}?{{ .app_js_checksum }}" defer></script>