forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 plugins => Topic started by: Mike_PL on March 01, 2008, 07:57:12 am

Title: Cache plugin for Coppermine?
Post by: Mike_PL on March 01, 2008, 07:57:12 am
Is avaliabe "cache plugin" for Coppermine Photo Gallery? Where?

Thanks.
Title: Re: Cache plugin for Coppermine?
Post by: François Keller on March 01, 2008, 08:25:52 am
what do you mean with cache plugin ?
Title: Re: Cache plugin for Coppermine?
Post by: Mike_PL on March 01, 2008, 02:21:45 pm
Hmm.. plugin like: http://mnm.uib.es/gallir/wp-cache-2/ (this is for Wordpress)
Title: Re: Cache plugin for Coppermine?
Post by: Joachim Müller on March 01, 2008, 03:30:05 pm
No, there's no page cache plugin for coppermine. Coppermine pages consist of much more dynamic data than a wordpress-driven page, that's why.
Why do you want a page cache? Is you site slow, or are you concerned about resources consumption? Both issues have been discussed before (in mayn different threads) - you should post a link to your gallery for a start and post what your actual problem is. A feature like a page-cache in itself doesn't help much - you need to know where your actual issue lies.
Title: Re: Cache plugin for Coppermine?
Post by: bitcloud on August 13, 2008, 05:03:20 am
I would also like to work out a cache plugin/mod for coppermine.

The reason is that some pages might get a lot of traffic while changing very little while others remain untouched.
A caching mod would display a cached version of a page and regenerate that cached version by a user definable interval.

It could even automatically begin caching a particular PID when the number of visiters per minute exceed a certain value.
Title: Re: Cache plugin for Coppermine?
Post by: Joachim Müller on August 13, 2008, 09:49:33 am
Sure, go ahead and post your results once you're done for the benefit of others.
Title: Re: Cache plugin for Coppermine?
Post by: bitcloud on August 13, 2008, 05:04:13 pm
OK, this is 1 possible solution... my code is perhaps a little clunky. Feel free to improve on it.

This caches for specific referrers... I've used frames in my original version to retain the integrity of the URL. If there is a better way of doing this, I'm all ears.

So if you put this in your displayimage.php file after "require('include/init.inc.php');" you should at least have an emergency incase of the dreaded "digg effect"

Code: [Select]
$sites = array('digg.com', 'slashdot.org', 'reddit.com', 'stumbleupon.com', 'engadget.com');
if(isset($_SERVER['HTTP_REFERER'])) {
$url = $_SERVER['HTTP_REFERER'];
$url = parse_url($url);
$spliturl = explode(".", $url['host']);
$lastpiece = count($spliturl);
$realurl = $spliturl[$lastpiece-2].".".$spliturl[$lastpiece-1];
if(in_array($realurl, $sites)) {
                        header('Location: http://'.$_SERVER['HTTP_HOST'].'.nyud.net:8080'.$_SERVER['REQUEST_URI']);
exit();
}
}
This will redirect ALL referrals from those domains to the cache. This may not be what you want, but will help you in a pinch.

To improve on this: Work out the intervals between page visits and if they fall under a certain level, you redirect to your cache... You'll need an "expiry" variable too because once it's reading from the cache, new intervals aren't being recorded.
(though what you can do is replace the "header" part of the above code with a frameset - to retain the URL integrity - and additionally in the upper frame you can record visits etc to avoid the expiry variable)

That way ONLY referrals from portal sites get redirected to the cache, and ONLY if the site is being accessed greater than X number of times a minute.

Add in a !USER_ID in there too and your registered users will never be pushed to a cache...
My version of the interval counter works, but I'm not 100% sure about it's quality yet so I won't post it here.