jan-herman / kirby-siteground-cache
Kirby cache driver for SiteGround web hosting.
Package info
github.com/jan-herman/kirby-siteground-cache
Type:kirby-plugin
pkg:composer/jan-herman/kirby-siteground-cache
Requires
- php: ^8.1
- getkirby/composer-installer: ^1.2
README
Kirby cache driver for purging SiteGround Dynamic Cache and controlling SiteGround cache headers from Kirby's pages cache configuration.
Installation
Install the plugin and enable it as the pages cache driver:
return [ 'cache' => [ 'pages' => [ 'active' => true, 'type' => 'siteground', ] ] ];
Options
maxAge
Set maxAge to send a Cache-Control: max-age=<seconds> header for rendered HTML pages. SiteGround uses this header to control how long the page should be kept in the Dynamic Cache.
return [ 'cache' => [ 'pages' => [ 'active' => true, 'type' => 'siteground', 'maxAge' => 6000, ] ] ];
If maxAge is not configured, the plugin does not send a cache lifetime header and SiteGround's default cache duration applies.
ignore
Use Kirby's native pages cache ignore option to exclude pages from SiteGround Dynamic Cache. Ignored pages send Cache-Control: no-cache.
return [ 'cache' => [ 'pages' => [ 'active' => true, 'type' => 'siteground', 'maxAge' => 6000, 'ignore' => fn ($page) => $page->template()->name() === 'contact', ] ] ];
You can also ignore pages by ID:
return [ 'cache' => [ 'pages' => [ 'active' => true, 'type' => 'siteground', 'ignore' => ['contact', 'private-area'], ] ] ];
Purging
Logged-in users can visit /flush-cache to purge Kirby's pages cache, which also purges SiteGround Dynamic Cache.
You can also purge the cache with the Kirby CLI:
vendor/bin/kirby clear:cache
Any code or command that calls kirby()->cache('pages')->flush() will trigger the SiteGround purge as well.