i want to cache my site, however i use query strings for certain features on all sites.
Pages with query strings are not cached. To clarify, i don’t need to cache queries as they are only used by JavaScript and don’t affect any content on the page. So i would like to have them cached.
that worked. so for others a sample code:
site/models/default.php
<?php
class DefaultPage extends Page
{
/* Forces Caching also for access via query string e.g. xyz?lang=en&refer=xyz */
public function isCacheable(): bool
{
// cache homepage for logged-out users
if ($this->isHomePage()) {
return kirby()->user() === null;
}
// Disable caching if:
// 1. Query string "preview" exists
// 2. A user is logged in
// 3. The page is a draft (status is "unlisted")
return empty(get('preview')) && kirby()->user() === null && $this->isListed();
}
}