alpshq/statamic-cache-evader
A Statamic addon that gives you fine-grained control over response caching. Evade or bypass the cache for specific URLs, requests, or user conditions, ensuring fresh content where it matters while the rest of your site stays fast. Simple configuration, no template changes required.
Statamic Cache Evader lets you keep Statamic's static/stache caching switched on while "punching holes" in a cached page for content that must be rendered fresh per visitor — a cart count, a logged-in username, a price, a stock level. The cached HTML contains a placeholder plus a signed URL; the browser fetches that URL and the package renders just the dynamic partial server-side.
First steps:
composer require alpshq/statamic-cache-evader:^1.4 — pin to at least 1.4.1. The signature-verification fix in 1.4.1 is a security patch, not a feature, so there is no reason to install an earlier 1.x.php artisan vendor:publish --tag="statamic-cache-evader-config" (confirm the exact tag with php artisan vendor:publish --list, since the tag name has varied across Alps packages).resources/views/layout.antlers.html) and wrap the single header region that shows user state in the package's dynamic tag, then load the page with static caching enabled and confirm the rest of the page is still served from the static cache while the header is fetched separately.Do not start by converting a whole page into a dynamic partial — the value of this package is that you convert almost nothing.
Hole-punching a cached layout. Keep the dynamic region as small and as low in the DOM as practical. The layout stays statically cached; only the wrapped include is rendered on the signed request. Anything you move inside the tag loses the benefit of static caching, so move only what genuinely varies per user or per request.
Passing context. Treat the parameters you hand to the partial as a public API: they end up encoded in a URL that the browser will send back. Anything sensitive (user IDs used for authorization decisions, prices used for charging) should be resolved server-side from the session, not taken from the URL, even with signature verification in place.
Endpoint hygiene. The render endpoint must not be cached by a CDN or reverse proxy — it returns per-visitor content. Verify the response carries Cache-Control: private, no-store (or that your edge rules exclude the route entirely). This is the most common way this pattern leaks data across users.
Testing. Write two feature tests against the render route: one asserting a properly signed URL returns 200 with the partial's HTML, and one asserting an unsigned URL, a URL with a tampered parameter, and a URL with a modified signature all return 403. That second test is the regression test for exactly the class of bug fixed in 1.4.1 — keep it.
Signed URL generation. If the package exposes a helper or facade for building the URL, use it in your own Blade/Antlers and in any custom JS. Do not hand-assemble the query string; hand-assembly is how projects silently drift into generating unsigned URLs and either break (post-1.4.1) or, before the patch, expose the endpoint.
APP_KEY invalidates every outstanding signed URL; on a multi-server deploy, rotate everywhere at once or use the dedicated key so a cache-evader-only rotation is possible.php artisan cache:clear && php artisan view:clear && php artisan route:clear && php artisan config:clear, plus php artisan statamic:static:clear — stale cached HTML can still contain old-format URLs, making the patch look like it broke things.php artisan route:list for the registered render route and confirm your signature middleware is actually in that route's middleware stack.local, so the bug class this package exists to solve does not reproduce there. Test with STATAMIC_STATIC_CACHING_STRATEGY (or the equivalent) set to a full-file strategy in staging before trusting it.How can I help you explore Laravel packages today?