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
Statamic Cache Directives

Statamic Cache Directives Laravel Package

daun/statamic-cache-directives

A Statamic addon by daun that adds Blade cache directives, letting you wrap template fragments in simple tags to cache rendered output and cut repeated rendering work on busy sites.

View on GitHub
Deep Wiki
Context7

Parse conditional comments for dynamic fragments in cached Statamic pages

Frequently asked questions about Statamic Cache Directives
What does daun/statamic-cache-directives actually do?
It is a Statamic addon that adds Blade cache directives you wrap around template fragments, so the rendered output is stored and reused instead of being rendered again on every request. It also parses conditional comments to handle dynamic fragments inside cached pages. This is most useful on busy sites where the same expensive fragment is rendered over and over.
How do I install daun/statamic-cache-directives?
Install it with Composer using composer require daun/statamic-cache-directives and commit the updated lock file. Then follow the registration steps in the repository README, which normally means the addon is auto-discovered by Statamic. Clear your application and Statamic caches after installing so the directives are picked up.
How do I use the cache directives in a Statamic template?
You wrap the fragment you want cached between the addon's opening and closing directives inside your template, and the rendered block is cached for later requests. The exact directive syntax and available options are documented in the repository README. Keep cached blocks small and scoped to a single template so invalidation stays predictable.
What are the conditional comments for dynamic fragments?
Cached blocks can depend on request-specific data such as the logged-in user, session state, or a query parameter. The addon uses conditional comment markers to decide whether a cached fragment can be reused or must be rendered fresh. That keeps personalised or dynamic pieces correct while the surrounding page stays cached.
Does this replace Statamic's static caching?
No, they solve different problems. Statamic's static caching stores whole responses at the web server level, while cache directives cache individual rendered fragments inside the template layer. That means fragment caching still helps on pages you cannot cache in full, and the two approaches can be combined.
Do I need to configure a cache driver or TTL?
Cached fragments live in Laravel's cache, so in production you should use a shared, persistent store such as Redis or Memcached instead of the array driver. Lifetime and invalidation behaviour are covered in the package README. Set lifetimes that match how often each fragment's underlying content changes.
Which template engine does it work with, Antlers or Blade?
The addon is described as providing Blade cache directives for Statamic templates. Confirm in the README which template contexts and Statamic versions are supported before relying on it in an existing project. If your site is Antlers-only, verify compatibility first rather than assuming it will work.
How do I clear cached fragments after content changes?
Because fragments are stored in Laravel's cache, they follow whatever cache store you have configured, so clearing the application cache or the relevant keys invalidates them. For content-driven fragments, keep TTLs short or clear the cache as part of your publish or deploy workflow. Statamic's own cache-clearing commands are a convenient place to hook that in.
Is it safe to run in production and is it actively maintained?
It is an open-source addon by daun, who maintains a set of small, focused Statamic packages. Check the repository for recent commits, tagged releases, and the stated support matrix against your Statamic and Laravel versions. Because fragment caching changes rendering behaviour, test it on staging with realistic traffic before enabling it in production.
What alternatives should I consider before adding this package?
Laravel ships its own @cache Blade directive from version 11 onward, which covers simple fragment caching without an extra dependency. Statamic's static caching and packages like spatie/laravel-responsecache handle full-response caching instead. This addon makes sense when you specifically want Statamic-aware handling of dynamic fragments inside cached pages.
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.
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
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager