getkirby / ideas

This is the backlog of ideas and feature requests from the last two years. Use our new feedback platform to post your new ideas or vote on existing ideas.
https://feedback.getkirby.com
20 stars 0 forks source link

Cache: when `cache` is true, don't load all of Kirby #17

Open ghost opened 6 years ago

ghost commented 6 years ago

@jenstornell commented on May 11, 2018, 7:56 AM UTC:

I'm only talking about the file cache in this issue

In Kirby 2 we can do this in config.php:

c::set('cache', true);

While it works to cache the template/snippet output, it still needs to load the whole Kirby, on every pageload.

global $kirby;
print_r($kirby);

c::set('cache', true);

I think there should be a better way to solve it.

Cache file in root

Instead of using config.php which require the whole Kirby system to run, maybe look for a file in the site root. It could for example be called CACHE.

Additionally it can contain information about the cache, for example type: file.

On cache fail

If the cache file does not exists, or the cached html file does not exists, run the Kirby system like normally.

In conclusion

The faster cache, the better. To skip the loading of the whole Kirby system on each page load, I think there is time to save.

Maybe it seems silly to only save a few milliseconds but in this fast web, it can make a big difference.

https://www.fastcompany.com/1825005/how-one-second-could-cost-amazon-16-billion-sales

This issue was moved by bastianallgeier from k-next/kirby#457.

ghost commented 6 years ago

@distantnative commented on May 11, 2018, 11:12 PM UTC:

To me it sounds like you want more a static page builder for Kirby?

ghost commented 6 years ago

@jenstornell commented on May 14, 2018, 4:25 AM UTC:

Not exactly. A static generator only loads the HTML files if they exists, else it will not work.

My idea here is to only load what is needed, when it's needed. If there is a cached file for the current page, load that and skip the whole Kirby load. If there is no cached file then Kirby needs to load which also caches the file for the next load.

ghost commented 6 years ago

@bastianallgeier commented on May 28, 2018, 10:21 AM UTC:

We could only introduce something like an "aggressive" cache option for this. Otherwise ignoring some pages with the ignore setting would not work.

The aggressive option could only be used though without exceptions. It's indeed almost like a static generator in that case.