Cache plugin for Coppermine? Cache plugin for Coppermine?
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Cache plugin for Coppermine?

Started by Mike_PL, March 01, 2008, 07:57:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Mike_PL

Is avaliabe "cache plugin" for Coppermine Photo Gallery? Where?

Thanks.

François Keller

what do you mean with cache plugin ?
Avez vous lu la DOC ? la FAQ ? et cherché sur le forum avant de poster ?
Did you read the DOC ? the FAQ ? and search the board before posting ?
Mon Blog

Mike_PL


Joachim Müller

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.

bitcloud

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.

Joachim Müller

Sure, go ahead and post your results once you're done for the benefit of others.

bitcloud

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"


$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.