Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Blade Cache Directive Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

ryangjchandler/blade-cache-directive is a micro-package that adds a @cache Blade directive (and a matching @endcache) to cache rendered template fragments. It is a single-purpose utility: it does not introduce a new caching backend, a service provider graph, or a data layer. Architecturally it is a thin ergonomic wrapper around Laravel's existing Cache facade, invoked at template render time.

Architecture fit. It fits cleanly wherever the application already uses the framework cache. There is no new infrastructure, no queue, no external service. The only architectural coupling is to Laravel's cache repository contract and to Blade compilation. For teams already comfortable with Cache::remember() in view composers or @php blocks, this is a readability improvement rather than a capability change.

Integration feasibility. Very high. A single composer require, no published config in the release notes, no migration, no service provider registration expected beyond package discovery. The v1.1.1 change is a composer constraint widening for Laravel 13.x — no runtime behavior change, no API change, no deprecation. Any application currently on Laravel 10/11/12 and PHP 8.x can adopt it in an afternoon.

Technical risk. Low in the abstract, but not zero, and the risks are the "silent correctness" kind rather than the "it won't boot" kind. Three stand out:

  1. Cache key hygiene. A fragment cache keyed only on route or template name will leak user-specific content across users. The directive must be given an explicit, discriminating key by the developer. This is a documentation and code-review problem, not a package defect, but it is the dominant failure mode.
  2. Invalidation semantics. Laravel's file and database cache stores do not support tags. Teams that adopt @cache assuming tag-based invalidation will discover at the worst possible moment that their only lever is TTL. Redis/Memcached are effectively required for anything with meaningful invalidation needs.
  3. Version-support breadth without version-support evidence. The "Laravel 13.x Compatibility" entry is a constraint bump from the Laravel Shift automation. It signals intent, not necessarily CI coverage against 13.x. Allowing a major version in composer.json before that major is stable is a reasonable forward-compatibility posture, but it means composer update can pull a combination that has never been executed.

Key questions for the maintainer / for our own review:

  • Does CI actually run the test suite against Laravel 13.x, or is the constraint the only change?
  • What is the documented guidance on cache key construction and per-user content?
  • Is there a recommended pattern for invalidation (tags vs. TTL vs. manual Cache::forget on model events)?
  • Is there an explicit support window / EOL policy for older Laravel majors?
  • What is the bus factor? Single maintainer, and this is one of several small packages.

Integration Approach

Stack fit. Excellent for a standard Laravel monolith or modular monolith on PHP 8.2+ where Blade is the rendering layer and the cache store is Redis or Memcached. Poor fit for API-only services (no Blade), for applications that have standardized on view composers plus Cache::remember (the package adds a second idiom for the same job), and for multi-tenant systems with heavy per-tenant cache partitioning unless key conventions are already established.

Migration path. There is nothing to migrate. Adoption is additive:

  1. Add the dependency on a branch.
  2. Convert one or two high-cost, low-personalization fragments — navigation, footer, marketing banners, expensive query-backed sidebars — from @php ... Cache::remember(...) ... @endphp to @cache(...).
  3. Leave personalized fragments alone initially.

If the team later wants to remove it, the reversal is mechanical: inline the Cache::remember call. There is no data migration, no schema, no lock-in beyond a small amount of template churn.

Compatibility. Requires a Laravel version within the package's constraint (now including 13.x) and an appropriate PHP version. The real compatibility question is the cache driver, not the framework: confirm the production store supports the invalidation strategy chosen (tags require Redis/Memcached).

Sequencing.

  1. Week 1 — spike. Add to a feature branch, cache a static navigation fragment, verify cache hits in the chosen store, confirm key uniqueness across tenants/users.
  2. Week 2 — guardrails. Write down the key-naming convention and TTL defaults; add a code-review checklist item for any new @cache usage; confirm the CI pipeline covers the Laravel version(s) actually deployed.
  3. Week 3+ — expand selectively. Move to fragments with measurable render cost. Instrument hit rate and render time before and after.
  4. Defer fragments that are user-scoped, permission-scoped, or price/inventory-sensitive until key design is proven.

Operational Impact

Maintenance. Negligible ongoing effort for the consuming team — the package is small, has no configuration surface to drift, and no scheduled jobs. The maintenance burden sits with the upstream maintainer, and that is where the genuine concern lies: a single-author package with a narrow user base. If it goes unmaintained, the fallback is a ~30-line replacement, so the exit cost is low. That materially reduces the strategic risk compared to, say, a single-author package that owns a persistence layer.

Support. Internal support load should be near zero if the guardrails above are in place. The likely support tickets are not "the package is broken" but "why is this page showing yesterday's pricing" — i.e., cache correctness incidents that would have occurred with hand-rolled caching too.

Scaling. The package itself does not scale; the cache store does. Caching fragment output reduces database and CPU load roughly in proportion to hit rate, which is the point. Watch for two second-order effects: Redis memory growth from large cached HTML blobs (consider compressing or shortening TTL), and cache stampede when a popular fragment expires under load — the directive does not appear to provide probabilistic early expiration or locking, so high-traffic fragments need jittered TTLs or a warm-up path.

Failure modes.

  • Stale content after a data change with no invalidation hook — most common, most visible.
  • Cross-user leakage from an under-specified cache key — least common, most severe; treat as a security-class defect.
  • Driver mismatch — assuming tags on a file/database store; fails silently or throws at runtime depending on call site.
  • Silent no-op if the cache store is misconfigured (e.g. array driver in an environment) — caching appears to work, provides no benefit, and hides the problem until load testing.
  • Framework-major upgrade surprise — the 13.x constraint bump is exactly the kind of change that lets a composer update proceed into an untested combination. Pin explicitly in CI.

Ramp-up. Hours, not days. A mid-level Laravel developer will read the README and be productive immediately. The non-obvious learning is entirely about cache key design and invalidation, which is framework knowledge rather than package knowledge.

Verdict. v1.1.1 is a maintenance release — a forward-looking compatibility constraint, no behavioral change, no breaking change, no deprecation. It does not alter the package's risk profile. The package is a reasonable, low-commitment convenience for teams doing fragment caching in Blade, provided the team owns key-naming conventions and does not assume tag support. It is not load-bearing infrastructure, and it should not be treated as such. Recommend adoption for non-personalized fragments, with the guardrails above, and no action required as a result of this specific release beyond confirming that our CI matrix matches the Laravel version we actually deploy.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource