Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GT Cache
#1
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...
Reply
#2
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.)
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
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
Reply
#4
A caching plugin would be a great idea. Obviously hook into "changedata-save" and drop the cache file for that page.
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#5
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!
Reply
#6
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.
Reply
#7
Well writing plugins in GS is so freaking simple and fast.....i just whipped up a backend for it...

[Image: gs_cache.jpg]
Reply
#8
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?
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#9
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.
Reply
#10
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.
- Julian

My GetSimple Plugins: Simple Image Gallery | TweetMeme reTweet Button
Reply
#11
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.
Reply




Users browsing this thread: 2 Guest(s)