Skip to content

cipi/cache 1.0.0 — purge Cipi's page cache from any PHP app - #1

Merged
andreapollastri merged 4 commits into
mainfrom
version-1.0.0
Nov 28, 2026
Merged

andreapollastri merged 4 commits into
mainfrom
version-1.0.0

Conversation

@andreapollastri

@andreapollastri andreapollastri commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

First release of cipi/cache, which purges Cipi's nginx page cache from any PHP app.

  • PageCache:
    • purge() takes a path (every domain of the app, with its ?utm variants), a prefix ending in *, or a URL on one of the app's domains.
    • Also: purgeUnder(), clear(), check(), and defer()/flush(), which send all of a request's purges in one call.
    • warm() requests pages again so they are cached before visitors arrive.
    • cacheFor()/neverCache() set the headers that let a response be cached, or not.
  • Runners:
    • SudoRunner runs sudo -n /usr/local/bin/cipi-cache-clear <app> <page>… on the server, without a shell.
    • ApiRunner calls POST /api/apps/{app}/cache/purge (cipi/api 1.48) from anywhere.
    • FakeRunner is for tests.
  • Laravel:
    • The provider and facade are auto-discovered; purgeRoute() and purgeRouteUnder() purge named routes.
    • Purges are sent when a request, job or command ends.
    • Middleware: cipi.cache[:seconds] and cipi.nocache.
    • The PurgesPageCache model trait, and the commands cipi:cache:purge and cipi:cache:check.

Tests. php tests/run.php runs 39 checks with nothing installed. CI covers PHP 8.1 to 8.4. The Laravel classes are only linted, not run inside a Laravel app.

https://claude.ai/code/session_0199AVTHoNdSA3aXMwVCa8b4

Review before release

  • cipi.cache did not work inside the web group. The group's middleware wrap the route's: StartSession and the CSRF middleware added their cookies after cipi.cache had removed them, so the page was never cacheable. cipi.cache now marks the request, and FinalizeCacheResponse — prepended to the HTTP kernel by the service provider — makes the response public once they are done. The Cookie header as sent decides who has no cookie.
  • PurgesPageCache reports a page that is not one instead of throwing from a model event (the row is saved by then).
  • CI now runs a real Laravel (Testbench, Laravel 11 and 12): the middleware in the web group, the model trait — green.

Generated by Claude Code

PageCache: purge by path, prefix or URL, clear, defer/flush, check, warm,
and the headers that let a response be cached (or not). Sudo runner on the
server, API runner from anywhere, fake runner for tests.

Laravel: facade with purgeRoute(), purges sent when a request/job/command
ends, cipi.cache and cipi.nocache middleware, PurgesPageCache model trait,
cipi:cache:purge and cipi:cache:check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199AVTHoNdSA3aXMwVCa8b4
…its cache

- The web group's middleware wrap the route's: StartSession and the CSRF
  middleware added their cookies after cipi.cache had removed them, so a page
  of a web route was never cacheable. cipi.cache now marks the request, and
  FinalizeCacheResponse — prepended to the HTTP kernel by the service
  provider — makes the response public once they are done. The Cookie header
  as sent decides who is a visitor without cookies.
- PurgesPageCache reports a page that is not one instead of throwing from a
  model event (the row is saved by then).
- CI: a Laravel job (Testbench, Laravel 11 and 12) runs tests/Laravel —
  the middleware in the web group, the model trait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199AVTHoNdSA3aXMwVCa8b4
…pendencies)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199AVTHoNdSA3aXMwVCa8b4
@andreapollastri
andreapollastri merged commit 1758693 into main Nov 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants