Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
beetraham
Regular
Regular



Joined: Dec 13, 2003
Posts: 94
Location: Finland (EU)

PostPosted: Mon Oct 04, 2004 9:51 pm Reply with quote

How to SUCCESSFULLY (***SAFELY***) configure PHP-Nuke's index.php with *jpcache* in case of applied frontpage caching?

::: BACKGROUND INFO :::

So, what is this issue about frontpage caching? Well, in most cases it is the frontpage, that has the extensive amount of content present, so from this point of view, the motive gets characterized by serious intetions on reducing the caused server load on frontpage accesses causing vast amount of MySQL Server Queries.

This short *code snippet insertion Guide* is not targetted on issues related to *How-To install jpcache* - instead it'll attempt to provide a short background description and the *code snippet* considered SAFE to use in case of frontpage caching with *jpcache*.

Should there be interest on *How-To* perform the *frontpage caching via jpcace utilization*, there are already very nicely formulated How-To's, so, should you fail to reach those - please let me know - I'll point out some references.


::: PHP-Nuke's index.php & jpcache - a dramatic speed-up SOLUTION for PHP-Nuke :::

As you may be aware of the various page caching availabilities, this *how to* is being dedicated for *safe PHP-Nuke frontpage jpcache utilization*.

What I'm trying to accomplish herein, is to provide a compact *safe code snippet insertion* example, which is considered to ensure that the PHP-Nuke frontpage (index.php) will get cached, neither by USERS nor ADMINS, but by UNREGISTERED/ANONYMOUS VISITORS ONLY.


::: PHP-Nuke & jpcache - talkin' bout frontpage SAFE caching :::

So, back to the main subject - How to SUCCESSFULLY (***SAFELY***) configure PHP-Nuke's index.php with *jpcache* in case of applied frontpage caching?

So, what you should be probably most concerned of, is the fact that the *frontpage* must not get cached by USER/ADMIN frontpage accesses.

And why's that? Well, IMHO the PHP-Nuke frontpage getting cached by USERS or ADMINS has to offer nothing but undesirable results from normal operations point of view. In that particular point of unwanted occasion, the USER / ADMIN cached page would be shown as a frontpage for ALL as-it-was-cached - including UNREGISTERED SITE VISITORS. Basically, whatever was there at the point of page getting cached.

So, clearly - there must be something to do to prevent this from happening. As I browsed some Threads *elsewhere*, I noticed that there really was a plenty of discussion related to subject, but unfortunately no directly applicable answer/"working solution" to it (famous last words). Rolling Eyes

Which brings us into the *simpler than simpler* solution - security experts may disagree (I'd be more than glad to hear their point of view from security point of view) - there certainly is far more cleverer ways of doing it, but here's what I came up with - tested, used, no complaints.

In case that you decide to utilize *jpcache for PHP-Nuke frontpage* caching, please include the following piece of code into the very beginning of the index.php page (you should still read the whole documentation to form the big picture): Laughing

::: THE CODE SNIPPET :::

|------> FIND A LINE

[<FILE> : index.php]

Quote:

require_once("mainfile.php");


|------> REPLACE THE LINE WITH FOLLOWING *example code snippet*

[<FILE> : index.php]

Quote:

require_once("mainfile.php");

// if the the user is logged in as a ADMIN (at the same time either or NOT, as an USER), we'll not use the page caching. Otherwise,
// if there's no username being set and the USER is NOT logged in as an ADMIN, we'll use the page caching. Otherwise,
// if none of the above (2) branches had a match, this means that user is logged in as a USER, hence we'll not use page caching.

// START OF JPCACHE (outer struct)
global $user, $admin, $cookie;
$username = $cookie[1];
if (is_admin($admin)) {
echo '';
} elseif ($username == "") {
// START OF JPCACHE (start of active utilization section)
$cachetimeout=900;
require ("includes/jpcache/jpcache.php");
// END OF JPCACHE (end of active utilization section)
} else {
echo '';
}
// END OF JPCACHE (outer struct)



Well, that's all.


Thanks,

BR,

-beetraham
 
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©