I talked to Remo about a better caching for concrete5.
I want to post a approach and a idea about how we can do it "better"! ;-)
Maybe Remo can also post his experiences and ideas here.
Let me know what you think. Hope to hear from you soon.
=== APPROACH: the PHP way ===
on our example pretty URLs are active. download the whole website (only .html files) with wget in a subdirectory called "cache" with ".htaccess" in it including "deny from all". The wget stuff can be done hourly in a cron job for example.
wget --recursive --no-host-directories --accept=html --exclude-directories=/files/,/index.php/ http://yourwebsite/
we replaced the content of the "index.php" in the root folder with something like this:
<?php
$filename = './cache/' . $_SERVER['REQUEST_URI'] . 'index.html';
if (file_exists($filename)) {
$x = file_get_contents($filename);
echo $x;
exit;
}
require('concrete/dispatcher.php');
Don't forget this is just an approach. Correctness of REQUEST_URI is not checked, etc. etc.!
speeds up everything because if a cached version of a site is avaible only the cached version is send out and concrete5 is not loaded in memory -> which means also no database querys etc. etc.
So this solution does not work with dynamic blocks (forum, guestbook etc. for example). But it would be possible to check if the request is a POST request and then it should not load the cached file and let concrete5 (dispatcher.php) do everything, etc. etc.
=== ANOTHER IDEA: mod_rewrite and stuff ===
for this idea we also keep a cached version of the pages in a subdirectory. If there is a request, we check with mod_rewrite, if the page exists as html file. If it is so, we send out that file. If not we let "index.php" (concrete5) do all the stuff.
so how can we keep the cached files up-to-date? one idea would be (like in the approach above) download the whole website (in a cron job for example). another idea is to save the whole page to the cache file, if the page gets edited in edit mode and saved (maybe this can be solved with the concrete5 events).
anyway we have to check with rewrite conditions, if there is a POST request to the server for example and then let the concrete5 index.php handle the request.
=== PROBLEMS ===
For both solutions we have to know which page has only static blocks (content blocks, flash blocks etc. for example). If a page has a guestbook or a forum it is not cacheable and so it should be handled via "index.php" and should not be cached.
Maybe it's possible to tag the blocks with something like "cacheable = true/false". If a page has a block with "cacheable = false" the whole page is not cacheable, so it is not written to the cache file and not handled via the PHP script (see approach) or mod_rewrite (see idea).
replace [SLASH] with "/"