Funky Cache (beta testers wanted)
|
291 posts
|
First of all I must say I was surprised how easy it was to create plugins for Frog. Core team has done a good job with the API. That said, I wanted to make Frog frontend faster than it is now. I tried Gilles’ File Cache plugin and that was an improvement. However I wanted to use funky caching which is one of the fastest caching techniques. Now I have first public version of plugin available. Code is only two evenings old so it would be great if people could beta test. So if you have time check the installation instructions. If you interested in number check the speed comparison. Code itself is at GitHub. Thanks once more to core team for clean understandable API and Gilles’ for inspiration. UPDATE: It seems that GitHub tarball generation is flaky. Use this download link instead. |
|
1493 posts
|
This is pretty nifty! I’ve grabbed it, installed, and had a little play. It looks very promising — especially with the “no-split” version of Frog on the horizon. Some issues for me: 1. I don’t use the “.html” suffix, and I didn’t make the alteration just to see what would happen. (The suffix breaks a sub-menu I use.) Without the suffix, the “Articles” page is broken; with the suffix, “Articles” works fine, but the menu is broken (I knew it would!). So it would be nice to have the suffix as optional! 2. It doesn’t seem to like Tagger. :/ When you click on a tag-link, I get a forwarding thing happening. I know this is “host” related, but I don’t suppose it should be happening at all. (The same thing happens when you try to remotely “hot-link” files from my site.) 3. The Contact form doesn’t seem to work? I’ll leave FunkyCache set up at TestFrog for now, with suffix, so the “CSS Play” page will not work. Later this evening, or tomorrow, I’ll turn it off though. |
|
1493 posts
|
P.S. It doesn’t like the Pagination “helper” either — see the “paging” links at the bottom of the Article page. Hopefully these are all “quick fixes”! :) |
|
291 posts
|
1. I don’t use the “.html” suffix, and I didn’t make the alteration just to see what would happen. This will be configurable later. Also needs more mod_rewrite rules. I have only spent two after-work evenings with the plugin so extra features follow later. 2. It doesn’t seem to like Tagger. Thanks for heads up. Will do some testing with those. Also the Funky Cache does not take comment plugin into account at the moment. |
|
316 posts
|
I think, for the .html problem, simply changing:
in FunkyCacheController.php to:
Should set it to be the same as set in config.php. |
|
486 posts
|
This is very promising, Tuupola! But like David, I don’t use .html suffix so won’t be able to test… |
|
291 posts
|
Archive pages should now work properly with both .html suffix and no suffix. Download again. Both versions also need special .htaccess file. Example .htaccess files included in plugin folder. |
|
316 posts
|
tuupola, is there any way of just making it use whatever is setup in the config.php? My site uses .xhtml and there’s going to be plenty of people who decide to change that to their own ideals. People could, for instance, use .php, .htm, .html, .xhtml, or, on one of my servers, .wish. Seeing as Apache can be set up to serve any extension as any other type of file, it’s plausible that someone might use .asp, .aspx, etc. The possibilities are endless. |
|
1493 posts
|
Hmmm… Something weird is going/has gone on. My articles page has stopped working. Weird. I’ve removed all caching, and reverted to no URL_SUFFIX, but “Articles” still doesn’t want to cooperate! Oh well. Will try to sort it later! |
|
1493 posts
|
OK. This is worth knowing about! I can only assume that funky_cache created an “articles” subdirectory in Frog’s root directory, and when I disabled caching, it was left behind. Of course, browsers now would look at the directory It would be great to get these wrinkles worked out, because as tuupola’s tests demonstrate, the performance gains are substantial. Thanks for your work on this, tuupola! |
|
291 posts
|
tuupola, is there any way of just making it use whatever is setup in the config.php? My site uses .xhtml Will be later. I am now first making it work properly with my own setup. Configurable items will come later. and when I disabled caching, it was left behind. Of course, browsers now would look at the directory Ah yes. Clearing cache only removes static files, not leftover folders. Will fix. |
|
291 posts
|
I made the cache file suffix configurable. Download latest to test. Short explanation is needed:
In all both cases (and depending on the suffix) mod_rewrite rules are different. Plugin will generate working .htaccess file for you. Click Your .htaccess file on sidebar and cut and paste it from there. |
|
486 posts
|
Is it compatible with Frog 0.9.3? |
|
291 posts
|
Have not tried myself. You know, I installed Frog for the first time last wednesday :) So I haven’t tried any older versions yet. |
|
1493 posts
|
@ricks – I can’t see why this wouldn’t work with 0.9.3 … there’s one way to find out! :)) @tuupola – what are the chances of funky_cache working without the URL-suffix kludge? I don’t mean just now … what you said above (“I am now first making it work properly with my own setup. Configurable items will come later.”) makes perfect sense! But on my tests so far, it would seem preferable for me to wait until there’s no URL suffix issue to contend with. I did test out the latest version. Again, it seemed to leave a fairly liberal sprinkling of directories behind it. Is there any way all the funky_cache pages could be consolidated into a single directory tree off the CMS root? Thanks again for your work on this. It has the potential to be a significant contribution! |
|
651 posts
|
@David et all I got Russel’s caching code from him and it seems fairly easy to implement, though if we integrate that into the Frog Core, it might collide with other caching solutions/plugins. @tuupola Me being either too lazy or simply too busy to do so (you decide ;-)… could you give us/me a short description of how your plugin does its work? Technically I mean. That would give me an idea of potential pitfalls and would allow me to way it against the solutions by Russel and Gilles. |
|
291 posts
|
what are the chances of funky_cache working without the URL-suffix kludge? I don’t mean just now … what you said above (“I am now first making it work properly with my own setup. Configurable items will come later.”) makes perfect sense! But on my tests so far, it would seem preferable for me to wait until there’s no URL suffix issue to contend with. Funky caching writes a static file to disc. For this file to be served as text/html it (usually) needs to have suffix such as .html, .xhtml, .php etc. I haven’t seen any implementation of funky caching which would write the static files to disc without suffix. I also don’t see how this would be possible. For example articles page and articles folder would clash with each other if there is no suffix
When there is suffix there is no problem
With the current version you can configure what the suffix (see my previous post). it would seem preferable for me to wait until there’s no URL suffix issue to contend with. Is there some other issue than configurable file suffix? Is there any way all the funky_cache pages could be consolidated into a single directory tree off the CMS root? Yes, that can be configured. One warning though. Then user must make sure search engines wont accidentally index this folder. I am aware of the issue and removing empty directories is in my TODO list. |
|
291 posts
|
@mvdkleijn It implements technique called “funky caching”. I think it was first time used by the *.php.net sites. Lets assume we have page at URL:
First time this page is accessed request goes to Frog. Frog generates the page and send it back to the browser. At the same time cache plugin writes the same content to webserver document root as static file called:
Next time the address http://www.example.com/about_us is requested mod_rewrite rules check is static file about_us.html exists. If it does webserver sends the static file. Request never reaches Frog or database.
There is nothing faster than serving static files. Then next time page is edited necessary static files are expired and generated again. Heart of the whole thing is correct mod_rewrite rules. They can be confusing to write. That is why plugin will generate them depending on Frog and plugin settings. |
|
109 posts
|
I like the idea of this plugin, but what if the information is dynamic. An instance would be that my homepage loads in a snippet that has a function to check a parent page and its children, now this is placed inside the layout that the homepage will use instead of the homepage. Each time i update the homepage it won’t have any effect on the layout so what happen if i should updated one of the parent page or children that the snippet collects, this won’t reflect on the homepage since the homepage is now static and i didn’t actually update it. |
|
316 posts
|
He did say that any time you update a Page, all the old static pages are deleted, so that the pages are re-cached. I don’t know if the same goes for snippets and layouts, though. |
|
486 posts
|
Does this include new comments posted to the page? |
|
651 posts
|
@tuupola Ok, technique understood. I’m not sure I like it though. (no offence intended) Granted, it should be very fast and efficient… but it has a number of drawbacks right of the bat:
but that’s just my gut instinct here.. I’m probably missing a couple of things. :-) |
|
291 posts
|
@easylancer I do not follow your explanation, but couple of points:
@ricks Yes. Page is updated when new comment is posted. Next time it is requested page is served from cache. Comment paging currently most like does not work. I did not test too much yet. BTW. Comment plugin itself throws quite many PHP Notices. @mvdkleijn Yes. Funky caching is not for faint hearted. It is most likely too complex for designer type of guys (no offense designer guys :) However:
It wont mess up directory structure if you know what you are doing. Blogging software I use (Mephisto) caches static files to document root and I have never had any problems. It is also possible to write the static files to their own folder for example DOCUMENT_ROOT/cache/. Then you do not any risk messing up something (and this actually is much cleaner way to do it).
As I said it is not for faint hearted :)
You misunderstood. It generates the mod_rewrite rules to you in admin interface so you can cut and paste them to your .htaccess file.
I do not follow. My blog is all dynamic. I still use funky caching. And if the site was static it would not need caching at all.
None. Spiders (nor normal users) never know if the content was served from static file or PHP backend. Bottom line. If you are not confident with mod_rewrite and friends I would rather use Giles’ File cache plugin. It gives nice speed improvement and you only need to click a checkbox to enable it. However if you are after absolute performance (handling Digg effect and being slashdotted) I would give funky caching a try. |
|
486 posts
|
Funky caching sounds great, but I was wondering what is the difference between this and File Cache Plugin, which describes itself thus:
It sounds like both do the same thing. How do you get such better performance from Funky Caching vs the File Cache plugin?
If this is the better way to do it, can this be set to the default behavior?
Does this mean you need a unique rewrite rule for every individual page? Thanks! |
|
291 posts
|
With File Cache plugin the request still goes to Frog. With my plugin the request never reaches Frog if page is cached. Rewrite rules check if cached file already exists. If it exists Apache serves the cached static file. Only if cache does not exist request is passed to Frog.
I just committed update which does just that. You can configure folder where plugin writes the cached files. This defaults to folder named cache. Folder is relative to document root. Webserver must have write access to that folder. If you do not have Git I also updated installation tarball to version 0.3.0. Remember to cut and paste rewrite rules to your .htaccess file from admin interface after updating or changing cache settings.
No. There is four different situations depending on Frog and plugin settings.
Each of these case have slightly different mod_rewrite rule. These might be really confusing to write by yourself. That is why I wrote a generator which after changing setting you can just click Your .htaccess file in admin and cut and paste working rewrite rules from there.
|

