Caching Pages with query (?xyz) (ignore query for caching)

Hi,

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.

So I would like that:

example.com/page/xyz
example.com/page/xyz?lang=en&refer=xy
example.com/page/xyz?lang=de&refer=eiuo

all get served the same cache version:
example.com/page/xyz

ist there a way to achieve this or any other workaround?

Thanks

You could overwrite the isCacheable() method in a page model.

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();
    }

}