ryangjchandler/blade-cache-directive
A lightweight Laravel package that adds an @cache Blade directive, letting you cache rendered fragments of views—partials, loops, or expensive blocks—with a TTL and optional key. Drop it into existing templates to cut rendering time without extra setup.
@cache / @endcache pair of Blade directives that store a rendered template fragment in Laravel's configured cache store under an explicit key and TTL. This lets you cut server render time and database load on specific expensive fragments (navigation, pricing tables, marketing modules, "related items" rails) without re-architecting the page or introducing a separate caching tier.Blade::directive in the app, a full-page cache layer (e.g. response caching), or object-level caching in repositories. This package is the cheapest option when the pain is view rendering specifically; it is not a substitute for query caching or a CDN.Adopt when most of the following hold:
Look elsewhere when:
file and you need tag-based bulk invalidation; that capability is not available.For executives: This is a small, low-risk performance lever, not a platform commitment. It lets engineering cache the slow, impersonal parts of high-traffic pages — the pieces that make pages feel slow during launches and peak load — without changing how the product works or investing in new infrastructure. The cost is measured in hours of implementation and a per-fragment freshness policy we define; the benefit is lower latency and less database load at exactly the moments that affect revenue and retention. The new release is a compatibility update for the next Laravel version, which means the approach stays supported through our upgrade roadmap and carries no migration work.
For engineering: One directive wrapping a fragment with a key and TTL; adoption is incremental and reversible per fragment. Two requirements before rollout: (1) every cached fragment must be provably impersonal or correctly key-scoped — cached HTML bypasses authorization and personalization logic, so a bad key is a data-leak class of bug, not a stale-content bug; (2) each fragment needs a named owner and invalidation strategy (TTL, key bump on deploy, or version segment) written down. Add cache hit/miss instrumentation per key so we can prove value and detect silent regressions. Pin the version and track the upstream repository; if maintenance lags behind a future Laravel release, plan to replace the directive with an in-house equivalent — a contained, low-effort fallback.
How can I help you explore Laravel packages today?