feat(makefile): add remote-warmup — clear + warm cache after deploy

A `reset --hard` content deploy leaves Grav's compiled-Twig/page cache
stale, so the first visitor pays the recompile. `remote-warmup` clears
the cache then crawls the public site (homepage + trips listing + every
trip page linked from it) to pre-render pages. Grav has no native warmup
command, so it's an HTTP crawl — which also doubles as a smoke test
(non-2xx pages flagged). Wired into REMOTE_TARGETS (-test/-prod variants)
and added as the final step in both deploy-cycle.md phases.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RDS6t8wcpbwKvvrxykVQ5K
This commit is contained in:
2026-07-08 13:05:33 +02:00
co-authored by Claude Opus 4.8
parent 3d9d3ecb85
commit 28e57f62c2
2 changed files with 32 additions and 1 deletions
+22 -1
View File
@@ -32,7 +32,7 @@ WEB_HOST ?= $(REMOTE_HOST)
REMOTE_TARGETS := remote-env-setup remote-env-remove remote-wipe remote-install \
remote-fetch remote-fetch-content remote-install-plugins remote-update-plugins \
remote-upgrade-grav remote-git-sync-disable remote-git-sync-enable \
remote-content-status remote-clean remote-diag remote-apply-env \
remote-content-status remote-clean remote-warmup remote-diag remote-apply-env \
remote-seed-api-salt remote-secrets-audit \
remote-gpm-install remote-maintenance-on remote-maintenance-off \
remote-apply-plugin-patches
@@ -284,6 +284,27 @@ remote-content-status: guard-env
remote-clean: guard-env
$(SSH) "cd $(WEBROOT) && php bin/grav clearcache"
# Post-deploy cache refresh: clear, then WARM. A `reset --hard` content deploy
# leaves Grav's compiled-Twig/page cache stale, and the first real visitor pays
# the recompile cost — so clear it and pre-render the public pages ourselves.
# Grav has no native warmup command, so this is an HTTP crawl of the live site:
# homepage + trips listing + every trip page linked from it (no sitemap plugin
# installed, so we scrape the listing instead of /sitemap.xml). The crawl runs
# from here over public HTTPS, so it also doubles as a smoke test — a non-200 on
# `/` is surfaced loudly. Run after every content deploy: `make remote-warmup-prod`.
remote-warmup: guard-env
$(SSH) "cd $(WEBROOT) && php bin/grav clearcache" >/dev/null
@base="https://$${WEB_HOST:-$(REMOTE_HOST)}"; \
echo "warming $$base (clear done) ..."; \
trip_urls=$$(curl -s "$$base/trips" | grep -oE '/trips/[a-z0-9][a-z0-9-]*' | sort -u); \
fail=0; \
for u in / /trips $$trip_urls; do \
code=$$(curl -s -o /dev/null -w '%{http_code}' "$$base$$u"); \
printf ' %-40s %s\n' "$$u" "$$code"; \
case "$$code" in 2*|3*) ;; *) fail=1;; esac; \
done; \
if [ "$$fail" = 1 ]; then echo "WARNING: one or more pages returned a non-2xx/3xx status"; else echo "warmup OK — all pages 2xx/3xx"; fi
# Install a single GPM package on the server (e.g. git-sync, which is
# intentionally NOT in plugins.txt — it is remote-only).
# Usage: make remote-gpm-install-prod PKG=git-sync