Download the PHP package aerni/dynamic-cache without Composer
On this page you can find all versions of the php package aerni/dynamic-cache. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aerni/dynamic-cache
More information about aerni/dynamic-cache
Files in aerni/dynamic-cache
Package dynamic-cache
Short Description Supercharge Statamic's static cache by dynamically excluding URLs that shouldn't be cached statically
License MIT
Homepage https://github.com/aerni/statamic-dynamic-cache
Informations about the package dynamic-cache
This addon has been archived in favor of the long-awaited nocache tag, which was introduced in Statamic v3.3.20.
Dynamic Cache
If you ever used Statamic's static caching with the full
strategy, you know that it doesn't play well with forms and dynamic listings like sort="random"
. This is where Dynamic Cache steps in. It dynamically updates the exclude
and invalidation rules
array in your static_caching.php
config based on a boolean in your entries' content.
Dynamic Cache is a lifesaver for sites with complex page builders based on Replicator and Bard. Your page builder might have dozens of components and only one requiring dynamic functionality. Without this addon, you'd have to do without full static caching because you'd never know which page actually included that one component that doesn't work when cached statically.
Features
- Adds your entries' URLs to the static caching
exclude
array - Populates the invalidation
rules
array - Updates the config whenever you save or delete an entry or change the structure of a collection
- Artisan Command to manually trigger a config update
Note: This addon currently only works with collection entries.
Installation
Install the addon using Composer:
Publish the config of the package:
The following config will be published to config/dynamic-cache.php
.
Configuration
You may change the field's handle that is used to check if an entry should be excluded from the static cache. The handle defaults to exclude_from_static_cache
.
Basic Usage
Dynamic Cache will look for exclude_from_static_cache: true
in your entries. The best way to add this value to your content is by creating a Fieldset with a Hidden Fieldtype and adding it to your Blueprints where necessary.
If you use a page builder, I suggest adding the Fieldset to every Replicator or Bard set that requires dynamic functionality. This way, the entry will only be excluded from the static cache if the component in question is present. If it is not, the entry will be cached statically.
Fieldset with Hidden Fieldtype:
Alternatively, you can also use a Toggle Fieldtype to manually turn the static cache on and off. Just note that this kind of defeats the dynamic problem this addon is trying to solve …
Fieldset with Toggle Fieldtype:
Manual Config Changes
You are free to manually change the exclude
and rules
array in the static_caching.php
config. Dynamic Cache is smart enough to merge your manual changes.
Invalidation Rules
This addon will not generate any invalidation rules if the config is set to rules => 'all'
.
Commands
You may update the config with the following command:
This is useful if you change your entries in your code editor rather than in the Control Panel.
Git Automation
This addon supports Statamic's Git integration. Simply add the following paths to the paths
array in your git.php
config. Also, make sure that the addon's storage path is tracked by git.
All versions of dynamic-cache with dependencies
statamic/cms Version ^3.0
stillat/proteus Version ^1.0
spatie/laravel-ray Version ^1.29