Project : frozen bread doug
Add a classical "webpage caching" feature (like joomla or CMS Made Simple) in WB would be cool, but as the core of WB wasn't conceived with "caching" in mind i know it can be a pain to add this feature, so i've an idea to make an even better system than the classical "caching" :
I think it would be great to have the possibility to "freeze" pages, by "freezing" i mean to transform the php pages from the modules into statics generated html files, then store theses html pages in the /temp directory (or another) and rewrite the php page (the file in pages directory) in a such way that it just hardlink the corresponding html page (include with an array to redirect the links to the static pages).
I'm thinking it just need theses modifications to work while keeping compatibility with existing modules :
-1 we should give a new possibility for modules developpers to inform if their modules support page freezing or not: for example a gallery, a wysiwyg section, or even a news section can benefit greatly of being freezed, on an other hand for rss feed readers, forms with captchas or ajax-based modules freezing would have no sense.
So module developpers who wants their modules pages being "freezable" just have to edit their info.php by adding a new variable :
$module_freezable = "true";
-2 in the table "pages" add fields "freezable" and "frozen" which are set to false by default.
-3 in the core file of WB, in "wb/admin/pages/add.php" make a require of "WB_PATH.'/modules/'.$module.'/info.php", you have to do this BEFORE adding the page in the DB (statement : "INSERT INTO ".TABLE_PREFIX."pages.....") so u can modify this statement to insert the value from "$module_freezable" into the sql field "freezable".Now we can easily know if the page is "freezable" by querying the DB, it will be useful for the next step.
-4 now we will be able to modify "wb/admin/pages/index.php" and to give user some controls to "freeze pages, for each line on the pages list we will have 3 possibilities:
- freezable is set to false -> just display the line.
- freezable is set to true and frozen is set to true -> display an icon to show that this page is frozen, if u want give the user ability to manually "unfreeze" pages u can even display a link to (warm_page($page_id,$section_id)) (explained later).
- freezable is set to true and frozen is set to false -> display a button or a link (to freeze the page) to a framework function (freeze_page($page_id,$section_id)) which will do the followings actions:
-crawl only the good pages (url of the links must match with page_id, section_id and be limited to the url of the website), each matching link must be stored in an array alongside with the corresponding links to the static generated html page
-for each matching page, generate html and store it were you decided.
-when the "site crawling" is over rewrite the "frozen" php page (the file in pages directory) in a such way that it just hardlink the corresponding html page (include with an array to redirect the links to the static pages).
-in the DB update the field "frozen" to true.
-5 we must make an another function (warm_page($page_id,$section_id)) which test if the page is frozen and then restore the php module page to its normal state (like when the page is generated by "wb/admin/pages/add.php") and set field frozen to false, this function will be called everytime the user modify the content of a "freezable module", the module developper will take care of it by calling the function everytime there's an action which modify the content displayed by the module.
Notice : this may help http://www.phpclasses.org/package/2253-PHP-Crawl-a-site-following-and-retrieving-linked-pages.html
What do u think about this idea ?
I'm sure this system can dramatically the speed in WebsiteBaker.
Here is my opinion on my "freezing page" concept :
- 100% compatible : it can be implemented into the core and WB and all the existings addons wil continue to work.
- once frozen a frozen page use less ressources than a regular page (don't have to check if cache must be freshen every time the page is displayed).
- can be easily implemented into existings modules (you can start with wysiwyg and news module to test it!).
- WB will be the "speed of light" CMS : with this system on a website where all the pages are frozen you can virtually have none sql query nor file access while displaying pages (there are no caching system i know with such features).
- if they wants their modules being "freezables", modules developpers will have to rework (slightly) their modules.
- modules developpers must be clever to understand how and when use freezing feature.
- can be tricky to code (i think to "website crawler" script.
- can be "ressource hungry" during crawling for writing the frozen pages.