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/"
staticCacheControl is a plugin that caches (and optionally gzips) Zenphoto pages on the file system to minimize PHP execution,
making your dynamic image gallery run as fast and light on resources as a static website.
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. :P With
staticCacheControl, you can have the best of both worlds.
staticCacheControl 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)
httpCacheControl 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. :P Oh well, I learned a LOT doing this.
Comments
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!
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
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.
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!
Thanks for your reply!
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?
Yes, i cleared the cache_html folder.
`Celebrities_Cameron Diaz-_en_US.html` so it looks like files in cache_html/albums folder.
Note that this is not supported and may not work with the current Zenphoto version. There is also a static cache plugin available btw.