[htdocs] css: add content hash to force refreshes as needed

Message ID 20231215025857.27816-1-vapier@gentoo.org
State New
Headers
Series [htdocs] css: add content hash to force refreshes as needed |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Mike Frysinger Dec. 15, 2023, 2:58 a.m. UTC
  Browsers will cache CSS files (a good thing), but we need to make sure
they refetch when the file changes, vs eventually expiring.  Add the
file hash to the query string so browsers refetch automatically.
---
 bugs/index.html                | 2 +-
 committee/index.html           | 2 +-
 committee/release-manager.html | 2 +-
 contribute/index.html          | 2 +-
 current/index.html             | 2 +-
 documentation/index.html       | 2 +-
 download/index.html            | 2 +-
 index.html                     | 2 +-
 index.sh                       | 8 ++++++--
 irc/index.html                 | 2 +-
 links/index.html               | 2 +-
 mailing-lists/index.html       | 2 +-
 mascot/index.html              | 2 +-
 news/index.html                | 2 +-
 news/reversible.html           | 2 +-
 papers/index.html              | 2 +-
 schedule/index.html            | 2 +-
 song/index.html                | 2 +-
 talks/index.html               | 2 +-
 testing/index.html             | 2 +-
 20 files changed, 25 insertions(+), 21 deletions(-)
  

Comments

Tom Tromey Dec. 15, 2023, 4:12 p.m. UTC | #1
>>>>> "Mike" == Mike Frysinger <vapier@gentoo.org> writes:

Mike> Browsers will cache CSS files (a good thing), but we need to make sure
Mike> they refetch when the file changes, vs eventually expiring.  Add the
Mike> file hash to the query string so browsers refetch automatically.

Seems like a good idea.  Thank you.

Tom
  

Patch

diff --git a/bugs/index.html b/bugs/index.html
index 09265446d361..7713f08cf5a3 100644
--- a/bugs/index.html
+++ b/bugs/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Bugs in GDB</title>
 
diff --git a/committee/index.html b/committee/index.html
index 54d4a64d6608..e08656e683c3 100644
--- a/committee/index.html
+++ b/committee/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>The Official FSF-appointed GDB Maintainers</title>
 
diff --git a/committee/release-manager.html b/committee/release-manager.html
index 05ccae35cb2f..7ce37a9bb756 100644
--- a/committee/release-manager.html
+++ b/committee/release-manager.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB Release Manager</title>
 
diff --git a/contribute/index.html b/contribute/index.html
index 16e0e4489031..c2b6e718471d 100644
--- a/contribute/index.html
+++ b/contribute/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Contributing to GDB</title>
 
diff --git a/current/index.html b/current/index.html
index 93084cb9a6dd..157eef9ce04d 100644
--- a/current/index.html
+++ b/current/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Current GDB</title>
 
diff --git a/documentation/index.html b/documentation/index.html
index c08253d87921..393f1c6a2513 100644
--- a/documentation/index.html
+++ b/documentation/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB Documentation</title>
 
diff --git a/download/index.html b/download/index.html
index 68a69a69f784..5ffce7831cdc 100644
--- a/download/index.html
+++ b/download/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Download GDB</title>
 
diff --git a/index.html b/index.html
index b619f5168b0a..1f8a92f4c432 100644
--- a/index.html
+++ b/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="css/site.css" />
+<link rel="stylesheet" href="css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB: The GNU Project Debugger</title>
 
diff --git a/index.sh b/index.sh
index eced31b7ec51..20f06b8b1d9d 100755
--- a/index.sh
+++ b/index.sh
@@ -30,6 +30,7 @@  fi
 cd `dirname $1`
 index=`basename $1`
 echo "$1"
+: "${AWK:=awk}"
 
 cp ${index} index.in
 exec > index.out
@@ -45,6 +46,9 @@  do
     prefix="../${prefix}"
     dir=`dirname ${dir}`
 done
+# Hash the CSS contents so browsers will refetch when the file changes.  The
+# exact query string in the URI used doesn't matter as long as it's different.
+css_hash=`md5sum < ${dir}/css/site.css | ${AWK} '{print $1}'`
 
 contents ()
 {
@@ -92,7 +96,7 @@  cat <<EOF
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="${prefix}images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="${prefix}css/site.css" />
+<link rel="stylesheet" href="${prefix}css/site.css?hash=${css_hash}" />
 
 <title>${title}</title>
 
@@ -120,7 +124,7 @@  cat <<EOF
 <!-- body, update above using ${prefix}index.sh -->
 EOF
 
-cat index.in | ${AWK:-awk} '
+cat index.in | ${AWK} '
 BEGIN { state = "head" }
 state == "head" && /<!-- body.*-->/ { state = "body"; next }
 state == "head" { next }
diff --git a/irc/index.html b/irc/index.html
index e3256967bc7b..53ae0de0d984 100644
--- a/irc/index.html
+++ b/irc/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>The GDB IRC Channel</title>
 
diff --git a/links/index.html b/links/index.html
index 68626369e247..bbbf56da18f6 100644
--- a/links/index.html
+++ b/links/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Sites and links related to GDB</title>
 
diff --git a/mailing-lists/index.html b/mailing-lists/index.html
index deaf7b31dbf4..c288ada27393 100644
--- a/mailing-lists/index.html
+++ b/mailing-lists/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB Mailing Lists</title>
 
diff --git a/mascot/index.html b/mascot/index.html
index 458f3ba74f9d..eaced56e5562 100644
--- a/mascot/index.html
+++ b/mascot/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB's Mascot?</title>
 
diff --git a/news/index.html b/news/index.html
index dd2482d82bab..2e7997a1e7b0 100644
--- a/news/index.html
+++ b/news/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB News</title>
 
diff --git a/news/reversible.html b/news/reversible.html
index bcaddbe571e0..b779dc396dbb 100644
--- a/news/reversible.html
+++ b/news/reversible.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB and Reverse Debugging</title>
 
diff --git a/papers/index.html b/papers/index.html
index e74e8b7af68c..d04bb4276597 100644
--- a/papers/index.html
+++ b/papers/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Various GDB Papers</title>
 
diff --git a/schedule/index.html b/schedule/index.html
index 843b67b1b24e..ce944bd6f812 100644
--- a/schedule/index.html
+++ b/schedule/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Release schedule for GDB</title>
 
diff --git a/song/index.html b/song/index.html
index ee5b59855a45..a02d2d96dbcb 100644
--- a/song/index.html
+++ b/song/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>Sing along with GDB</title>
 
diff --git a/talks/index.html b/talks/index.html
index a3000bcf8e26..493d4acb688d 100644
--- a/talks/index.html
+++ b/talks/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB Talks and Lectures</title>
 
diff --git a/testing/index.html b/testing/index.html
index 19cebd4be00c..76fe0a750974 100644
--- a/testing/index.html
+++ b/testing/index.html
@@ -9,7 +9,7 @@ 
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <link rel="shortcut icon" type="image/x-icon" href="../images/archer-fish.ico" />
 <meta name="keywords" content="gdb" />
-<link rel="stylesheet" href="../css/site.css" />
+<link rel="stylesheet" href="../css/site.css?hash=54990fef3ff3855a54d10cd61077e249" />
 
 <title>GDB Test Farms</title>