From c66f785fcb65d24ef3a00d0e058322536f078e52 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Fri, 11 Aug 2023 12:03:17 -0400 Subject: [PATCH] Implement cache busting (#337) --- src/account/create.html | 7 ++++--- src/account/index.html | 9 +++++---- src/account/login.html | 7 ++++--- src/account/logout.html | 7 ++++--- src/account/register-package.html | 7 ++++--- src/account/reset-password.html | 7 ++++--- src/account/verify.html | 7 ++++--- src/business.html | 3 ++- src/docs/index.html | 3 ++- src/docs/json/index.html | 9 +++++---- src/docs/modules/index.html | 9 +++++---- src/download.html | 7 ++++--- src/includes/account/head.html | 13 ++++++++----- src/includes/docs/head.html | 21 ++++++++++++--------- src/includes/head.html | 15 ++++++++++++--- src/index.html | 5 +++-- src/v2.html | 5 +++-- 17 files changed, 85 insertions(+), 56 deletions(-) diff --git a/src/account/create.html b/src/account/create.html index 63a0905..f40eb78 100644 --- a/src/account/create.html +++ b/src/account/create.html @@ -2,8 +2,9 @@ Create Account - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} +
@@ -25,4 +26,4 @@
- \ No newline at end of file + diff --git a/src/account/index.html b/src/account/index.html index 8d58bf5..f1d7ec7 100644 --- a/src/account/index.html +++ b/src/account/index.html @@ -2,9 +2,10 @@ Dashboard - Caddy - {{include "/includes/account/head.html"}} - - + {{import "/includes/account/head.html"}} + {{template "account-head"}} + +
@@ -29,4 +30,4 @@
- \ No newline at end of file + diff --git a/src/account/login.html b/src/account/login.html index aa81a3a..abfe73a 100644 --- a/src/account/login.html +++ b/src/account/login.html @@ -2,8 +2,9 @@ Log In - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} +
@@ -22,4 +23,4 @@
- \ No newline at end of file + diff --git a/src/account/logout.html b/src/account/logout.html index dce0666..ba8ead9 100644 --- a/src/account/logout.html +++ b/src/account/logout.html @@ -2,10 +2,11 @@ Logout - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} + Logging out... - \ No newline at end of file + diff --git a/src/account/register-package.html b/src/account/register-package.html index 625a163..cf07d3d 100644 --- a/src/account/register-package.html +++ b/src/account/register-package.html @@ -2,8 +2,9 @@ Register Package - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} +
@@ -39,4 +40,4 @@
- \ No newline at end of file + diff --git a/src/account/reset-password.html b/src/account/reset-password.html index c20b46d..4c466c5 100644 --- a/src/account/reset-password.html +++ b/src/account/reset-password.html @@ -2,8 +2,9 @@ Reset Password - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} +
@@ -35,4 +36,4 @@
- \ No newline at end of file + diff --git a/src/account/verify.html b/src/account/verify.html index 87a1044..132d152 100644 --- a/src/account/verify.html +++ b/src/account/verify.html @@ -2,8 +2,9 @@ Confirm Account - Caddy - {{include "/includes/account/head.html"}} - + {{import "/includes/account/head.html"}} + {{template "account-head"}} +
@@ -21,4 +22,4 @@
- \ No newline at end of file + diff --git a/src/business.html b/src/business.html index df41579..96c0e31 100644 --- a/src/business.html +++ b/src/business.html @@ -2,7 +2,8 @@ Caddy for Business - {{include "/includes/head.html"}} + {{import "/includes/head.html"}} + {{template "head"}} diff --git a/src/docs/index.html b/src/docs/index.html index 144fb9d..98960de 100644 --- a/src/docs/index.html +++ b/src/docs/index.html @@ -8,7 +8,8 @@ {{$title}} — Caddy Documentation - {{include "/includes/docs/head.html"}} + {{import "/includes/docs/head.html"}} + {{template "docs-head"}} diff --git a/src/docs/json/index.html b/src/docs/json/index.html index dde87fe..9ecea52 100644 --- a/src/docs/json/index.html +++ b/src/docs/json/index.html @@ -2,11 +2,12 @@ JSON Config Structure - Caddy Documentation - {{include "/includes/docs/head.html"}} - + {{import "/includes/docs/head.html"}} + {{template "docs-head"}} + - - + + {{include "/includes/docs/header.html"}} diff --git a/src/docs/modules/index.html b/src/docs/modules/index.html index b03e90e..7ffb20d 100644 --- a/src/docs/modules/index.html +++ b/src/docs/modules/index.html @@ -2,11 +2,12 @@ Modules - Caddy Documentation - {{include "/includes/docs/head.html"}} - + {{import "/includes/docs/head.html"}} + {{template "docs-head"}} + - - + + {{include "/includes/docs/header.html"}} diff --git a/src/download.html b/src/download.html index 7cd54b4..43a7025 100644 --- a/src/download.html +++ b/src/download.html @@ -2,11 +2,12 @@ Download Caddy - {{include "/includes/head.html"}} - + {{import "/includes/head.html"}} + {{template "head"}} + - +
diff --git a/src/includes/account/head.html b/src/includes/account/head.html index c95ac06..2ff15c3 100644 --- a/src/includes/account/head.html +++ b/src/includes/account/head.html @@ -1,5 +1,8 @@ -{{include "/includes/head.html"}} - - - - \ No newline at end of file +{{define "account-head"}} + {{import "/includes/head.html"}} + {{template "head"}} + + + + +{{end}} diff --git a/src/includes/docs/head.html b/src/includes/docs/head.html index c7525cc..be64df1 100644 --- a/src/includes/docs/head.html +++ b/src/includes/docs/head.html @@ -1,10 +1,13 @@ -{{include "/includes/head.html"}} - - -{{$directives := list }} -{{range $i, $file := (listFiles "/docs/markdown/caddyfile/directives")}} - {{$directives = append $directives ($file | trimSuffix ".md")}} +{{define "docs-head"}} + {{import "/includes/head.html"}} + {{template "head"}} + + + {{$directives := list }} + {{range $i, $file := (listFiles "/docs/markdown/caddyfile/directives")}} + {{$directives = append $directives ($file | trimSuffix ".md")}} + {{end}} + + + {{end}} - - - \ No newline at end of file diff --git a/src/includes/head.html b/src/includes/head.html index 2159aa9..d917d78 100644 --- a/src/includes/head.html +++ b/src/includes/head.html @@ -1,12 +1,20 @@ +{{define "cacheBust" -}} + {{- if fileExists "/.commit-hash" -}} + {{- $commitHash := (include "/.commit-hash") -}} + {{- trim (printf "?v=%v" $commitHash) -}} + {{- end -}} +{{- end}} + +{{define "head"}} - + - - + + @@ -41,3 +49,4 @@ +{{end}} diff --git a/src/index.html b/src/index.html index 563a800..98905ec 100644 --- a/src/index.html +++ b/src/index.html @@ -2,8 +2,9 @@ Caddy - The Ultimate Server with Automatic HTTPS - {{include "/includes/head.html"}} - + {{import "/includes/head.html"}} + {{template "head"}} + diff --git a/src/v2.html b/src/v2.html index b846bef..c300746 100644 --- a/src/v2.html +++ b/src/v2.html @@ -2,10 +2,11 @@ Caddy 2 - {{include "/includes/head.html"}} + {{import "/includes/head.html"}} + {{template "head"}} - +