From 6d1b0f0b16bdfd685cd5e6428abcbcc968503352 Mon Sep 17 00:00:00 2001 From: astrovm <~@4st.li> Date: Sat, 3 Oct 2026 15:09:42 -0300 Subject: [PATCH] Invalidate Cloudflare cache after Pages deploys Marks this site's cached copies stale after each deploy, so a long Cloudflare edge cache can be used without serving stale pages. Co-authored-by: Claude Opus 5.5 --- .github/workflows/cloudflare-cache.yml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/cloudflare-cache.yml diff --git a/.github/workflows/cloudflare-cache.yml b/.github/workflows/cloudflare-cache.yml new file mode 100644 index 0000000..1e17ef3 --- /dev/null +++ b/.github/workflows/cloudflare-cache.yml @@ -0,0 +1,32 @@ +name: Invalidate Cloudflare cache + +# Runs after GitHub Pages publishes a new build of this site. +on: + workflow_run: + workflows: [pages-build-deployment] + types: [completed] + workflow_dispatch: + +permissions: {} + +concurrency: + group: cloudflare-cache + cancel-in-progress: false + +jobs: + invalidate: + if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-26.04 + timeout-minutes: 5 + steps: + - name: Invalidate Cloudflare cache + env: + CLOUDFLARE_CACHE_TOKEN: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} + # Marks cached copies stale so the edge revalidates them against the new deploy. + run: | + curl --fail-with-body --silent --show-error --retry 3 --retry-all-errors \ + --request POST \ + --header "Authorization: Bearer $CLOUDFLARE_CACHE_TOKEN" \ + --header "Content-Type: application/json" \ + --data '{"hosts":["anomalous.xyz","www.anomalous.xyz"]}' \ + "https://api.cloudflare.com/client/v4/zones/66108efdf9f66064614f61b62d623f5e/invalidate_cache"