After working on HTTP Cache Control for ZP, I decided to try to bypass PHP processing altogether in an attempt to make ZP run as fast and light as a static website. I think I succeeded, albeit not in the most elegant manner. ^_^
http://www.tummblr.com/my-code/zenphoto-plugin-static-cache-control/
"[b]staticCacheControl[/b] is a plugin that caches (and optionally gzips) Zenphoto pages on the file system to minimize PHP execution, [b]making your dynamic image gallery run as fast and light on resources as a static website[/b].
No matter how well you optimize PHP processing through code optimizations, opcode and database query caching, a dynamic PHP application still can't beat the performance (speed/time, CPU/memory usage) of a website with the same content displayed using static HTML files. However, good luck updating thousands of static HTML pages by hand. With [b]staticCacheControl[/b], you can have the best of both worlds.
[b]staticCacheControl[/b] automates the process of generating static HTML copies of your Zenphoto pages, redirecting visitors to these cached pages when possible, and also the validating/refreshing of the static cache when your Zenphoto pages change. Thus, you can enjoy the performance of static pages without the hassle of updating them manually.
This plugin is designed for use in the album.php, albumarchive.php, image.php, index.php of your theme. It can be used in conjunction with (after) [b]httpCacheControl[/b] for optimal results."
I wonder if I've gone overboard with my attempts at optimizing Zenphoto's performance since ZP's quite snappy on its own. Oh well, I learned a LOT doing this.
I'd be very happy if this feature made it into Zenphoto. Before that happens though, I hope that the programming guru's around here can inspect the code and design. staticCacheControl and httpCacheControl are untested on a live site (waiting for a slice from Slicehost grrr), and I'm a newbish coder.
I'll make a Trac ticket in a bit.
Right now, all the code resides in static_cache_control.php, and you just need to include and execute 1 function in your theme file. No zp-core modifications are necessary yet, so please give it a whirl!
to tummblr:
can you help me please, what am I doing wrong?
I added to index.php your code:
include_once('zp-core/static_cache_control.php');
// get $mtime from other function/code, ex.
// $mtime = httpCacheControl(FILE);
// also enable gzip of cached files
staticCacheControl(FILE, $mtime, true);
But I got the error:
Fatal error: Call to undefined function: in_context() in /home/my_user_folder/public_html/zenphoto/zp-core/static_cache_control.php on line 290
The code should be inserted in your theme files, not index.php in Zenphoto's root. For example, using the "default" theme:
Place static_cache_control.php in /zenphoto/themes/default
Insert at the top of /zenphoto/themes/default/index.php
`include_once('static_cache_control.php');
staticCacheControl(FILE);`
You can't call the function with $mtime if you don't already have that value from somewhere else. If you omit the second parameter, staticCacheControl() will attempt to calculate it.
Hi All!
I have trouble with this plugin on my site: http://wallpaperstock.eu
index and album pages are ok, but on image page I have the same pictures.
maybe my theme is outdated or this is a bug?
Thanks for your help!
The static cache control this thread is actually about is not the same as the static-html-cache plugin. The first one is found here on our "hacks" page: http://www.zenphoto.org/2008/06/performance-hacks. I never tried that hack and have not tested it with the static html cache plugin. If you use both together that could be the reason.
Alright, just wanted to be sure about the issue. Thanks for the ticket.
Actually I don't see why that plugin in should have this weird effect nor did I ever noticed that. Are the permissions correctly set on the cache_html folder? Did you clear the cache_html folder?
I would love to use this plugin, but the link in the first post is dead. Does it still exist? Could anyone re-upload it so others can continue to use it?
Sorry, there is this old ticket where you can download a file: http://www.zenphoto.org/trac/ticket/318
Note that this is not supported and may not work with the current Zenphoto version. There is also a static cache plugin available btw.