Posts: 47
Threads: 13
Joined: Mar 2010
2010-03-25, 07:05:42
(This post was last modified: 2010-03-25, 07:09:12 by luisvaloyes.)
Would it make sense to make GT cachable?
For pages that use many xml requests, api's etc. this might make sense....
Maybe in the lines of: (just wrote code here...not tested)...
<?php
// check if cache file exists
if (file_exists('data/cache/'.$file.'.cache')) {
// check how old cache file is...and use it or rewrite it
if(date("d-m-y", filemtime('data/cache/'.$file.'.cache)) > datetime(+24hrs)){
// Read cache file
readfile('data/cache/'.$file.'.cache');
exit();
}
}
// Start buffering the output
ob_start();
// Display some HTML
?>
--- HTML CONTENT ---
<?php
$buffer = ob_get_contents();
ob_end_flush();
$fp = fopen('data/cache/'.$file.'.cache', 'w');
fwrite($fp, $buffer);
fclose($fp);
?>
one could think of adding memcache in the loop as well...
Posts: 972
Threads: 27
Joined: Aug 2009
There is actually very little that will need caching in my opinion. A cached file will need to be read, just like the standard XML file. In my opinion the only thing that would need caching is the menu, as every time the menu needs to be generated it needs to read each and every file. Cutting this one down to only one file will save a lot of file calls. (I’m thinking about getting that setup in my plugin.)
Posts: 47
Threads: 13
Joined: Mar 2010
Well...the parsing of the XML could be cached for one..no need to have PHP in the loop all the time...
But as i said..i believe multi-page xml read's (like the menu) as well as API calls to external servers could and should be cached.
I just tried caching the menu and the change was indeed significant:
Default:
This page was rendered in 0.027153968811 seconds
Cached menu:
This page was rendered in 0.00131392478943 seconds
Posts: 161
Threads: 6
Joined: Jan 2010
A caching plugin would be a great idea. Obviously hook into "changedata-save" and drop the cache file for that page.
Posts: 1,848
Threads: 86
Joined: Aug 2009
I like the ieda of a cache plugin - i think it would also be great if there was a button on the admin side to delete all cache pages (for ideas look at donncha's wp-super-cache plugin for WP)
-
Chris
Thanks for using GetSimple! - Download
Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Posts: 47
Threads: 13
Joined: Mar 2010
Well here is a quicky then
Just add the plugin..and all files will be cached to /data/cache (make sure directory exists and its writabable)
All cached files have the following comment ammended to the end
<!-- Page cached on Thursday 25th of March 2010 11:26:21 AM-->
Files are cached for 48 hours..then recreated..(check the param $time_limit)
This is very basic..but I guess its a start.
I guess next version will bring what Chris said..a little admin panel in the back...where one can define cache time and clear cached files.
Posts: 47
Threads: 13
Joined: Mar 2010
2010-03-26, 18:12:50
(This post was last modified: 2010-03-26, 18:46:53 by luisvaloyes.)
Well writing plugins in GS is so freaking simple and fast.....i just whipped up a backend for it...
Posts: 972
Threads: 27
Joined: Aug 2009
Can I ask what pages it caches? Because at some point if you’re just caching everything by standard you could just as well rewrite GS to not use a XML backend for its pages but save everything in the form of HTML-files directly.
Maybe there should be something like always caching the menu and only caching single pages when they reach a certain amount of hits per day?
Posts: 47
Threads: 13
Joined: Mar 2010
Well at the moment it caches all pages...and yes...indeed you could make it rewrite that everything uses the static html's...
my next step would be to include fragment caching etc.
Full Page caching is the first step...and should be sufficinent for the majority of uses.
Posts: 196
Threads: 16
Joined: Mar 2010
nexflo Wrote:Well at the moment it caches all pages...and yes...indeed you could make it rewrite that everything uses the static html's...
my next step would be to include fragment caching etc.
Full Page caching is the first step...and should be sufficinent for the majority of uses.
What if the page you are caching has a plugin attached to it. Meaning that a plugin is using a filter hook to modify the content of the page in a dynamic way.
Posts: 47
Threads: 13
Joined: Mar 2010
Well that depends how exactly the plugin is changing the page...
if the page looks diffrent EVERY time...obviously you dont need caching at all..or just use fragment caching for parts of the page then...menu, sidebar, etc.