Skip to content

Automatically busts cache when entries and collections within the autotag are changed

Notifications You must be signed in to change notification settings

tv2regionerne/statamic-cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Statamic Autocache

Statamic Autocache is an addon that automatically caches the content of any partials for a faster response time and selective invalidation

How to Install

Run the following command from your project root:

composer require tv2regionerne/statamic-cache

Then run the migrations:

php artisan migrate

You can also optionally publish the config:

php artisan vendor:publish --tag=statamic-cache-config

How to Use

The addon should work automatically in most cases. It adds hooks to partial, nav and collection tags, as well as augmentation of entries and globals to determine what content is included in what partials. This data is then added to a database store that is used to determine what cached data should be invalidated at what times.

The default cache is used, or you can specify a cache store called statamic_autocache if you want to have more control over when it is cleared.

Middleware

The autocache middleware will automatically be added to your web middleware stack. If you want to include it to other stacks simply add:

\Tv2regionerne\StatamicCache\Http\Middleware\Autocache::class

Store

The addon comes with a Facade for interacting with the Store: \Tv2regionerne\StatamicCache\Facades\Store

If you want to add extra data to the store you can do so using in your AppServiceProvider, eg:

MyTag::hook('init', function () {
	Store::mergeTags(['my_tag:id']);
});

Make sure you also invalidate the tag in a listener:

Store::invalidateContent(['my_tag:id']);

About

Automatically busts cache when entries and collections within the autotag are changed

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages