I have a SPA (single page application) build with Kirby, everything works like a charm, super system getkirby is.
I am doing a conditional within footer.php and header.php
$isAjax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
I use this to exclude content ex. tag and other unnecessary content when the request is an ajax call. This keeps requests light.
If I have caching enabled.
then it caches the ajax call as a “standard” http request of the whole page. So if I refresh the page I only get a partial page (ex. no tag).
Is there a was to get finer control over what get’s inserted into the cache and what get’s fetched from the cache?
In theory I would like to
- if ajax call, then make sure to save the whole page as well
- when retrieving a cache item, then check for an ajax parameter (maybe a header?) and retrieve the appropriate cache item.
Hope it makes sense.