Member
Member
tummblr   2007-12-01, 04:27
#1

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.

Member
Member
tummblr   2007-12-02, 08:15
#2

staticCacheControl now supports comments.

Member
Member
aitf311   2007-12-02, 15:27
#3

tummblr, you should create a ticket in trac if you are going to be modifying the zp-core. It looks like this is definitely something that should be integrated in the distribution if you do not mind?!

Member
Member
tummblr   2007-12-02, 18:33
#4

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!

Member
Member
yurymad   2007-12-03, 06:10
#5

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

Member
Member
tummblr   2007-12-03, 06:51
#6

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.

Member
Member
yurymad   2007-12-03, 07:31
#7

Thanks for your help, it works! You've done great job!

Member
Member
suxab   2008-11-10, 11:50
#8

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!

Administrator
Administrator
acrylian   2008-11-10, 13:14
#9

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.

Member
Member
suxab   2008-11-10, 13:23
#10

sorry for bad topic, i´m using just the "static-html-cache" plugin provided by zenphoto (svn2869).
Thanks for your reply!

Administrator
Administrator
acrylian   2008-11-10, 14:50
#11

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?

Member
Member
suxab   2008-11-10, 14:55
#12

cache_html and subfolders have permission 777, cache files have 606.
Yes, i cleared the cache_html folder.

Member
Member
suxab   2008-11-10, 15:03
#13

in cache_html/images folder are cache filenames without image filenames, for example:
Celebrities_Cameron Diaz-_en_US.html so it looks like files in cache_html/albums folder.

Administrator
Administrator
acrylian   2008-11-10, 18:08
#14

I could reproduce it and found the error, a small typo... So it will be fixed in tonight's nightly.

Member
Member
suxab   2008-11-10, 20:16
#15

thanks for your quick patch, now its work great, but search pages are empty /are cached/

Member
Member
nothingless   2009-01-28, 14:26
#16

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?

Administrator
Administrator
acrylian   2009-01-28, 16:25
#17

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.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.