Skip to content

Commit

Permalink
chore: try to control caching by adding meta cache tags (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
kilianc authored May 17, 2024
1 parent 0cd5af9 commit 73eaec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<title>Waiting for GitHub Pages Deployment</title>
<style>
* {
Expand Down
13 changes: 8 additions & 5 deletions scripts/push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ cp incremental.out "${cover_dir}/revisions/${REVISION}-inc.o

cd "${cover_dir}"

# copy assets

cp "${GITHUB_ACTION_PATH}"/assets/* .

# beautify html

# this is useful for browser caching
hash=$(cat index.css index.js | md5sum | awk '{print $1}')

for file in "revisions/${REVISION}.html" "revisions/${REVISION}-inc.html"; do
ex -sc '%s/<\/style>/<\/style><script src="..\/index.js?'"${hash}"'"><\/script>/' -c 'x' "${file}"
ex -sc '%s/<\/style>/<\/style>\r\t\t<script src="..\/index.js?'"${hash}"'"><\/script>/' -c 'x' "${file}"
ex -sc '%s/<title>/<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" \/>\r\t\t<title>/' -c 'x' "${file}"
ex -sc '%s/<title>/<meta http-equiv="Pragma" content="no-cache" \/>\r\t\t<title>/' -c 'x' "${file}"
ex -sc '%s/<title>/<meta http-equiv="Expires" content="0" \/>\r\t\t<title>/' -c 'x' "${file}"
done

# if we are on the main branch, copy files to main.*
Expand All @@ -44,10 +51,6 @@ if [ "${REF_NAME}" = "main" ]; then
cp "revisions/${REVISION}.out" "${cover_dir}/head/head.out"
fi

# copy assets

cp "${GITHUB_ACTION_PATH}"/assets/* "${cover_dir}"

# push to branch

git add .
Expand Down

0 comments on commit 73eaec5

Please sign in to comment.