Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: try to control caching by adding meta cache tags #46

Merged
merged 3 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading