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
Poll
Was this of value to you
Yes
100%
 100%  [ 4 ]
No
0%
 0%  [ 0 ]
Total Votes : 4


Author Message
telli
New Member
New Member


Joined: Sep 24, 2003
Posts: 21

PostPosted: Mon Feb 23, 2004 12:44 am Reply with quote

telli wrote:
define ('NUKER',1);

I added that in the mainfile directly above the code as described and It hosed the whole site.

Code:
Warning: main(/includes/Cache_Lite/Lite.php): failed to open stream: No such file or directory in /var/www/html/mainfile.php on line 23


Fatal error: main(): Failed opening required '/includes/Cache_Lite/Lite.php' (include_path='.:/php/includes:/usr/share/php') in /var/www/html/mainfile.php on line 23


And the file is there and functioning i use it on all the blocks.


Disregard just my shafty coding Embarassed
 
View user's profile Send private message Visit poster's website
Paul_K
Hangin' Around


Joined: Feb 22, 2004
Posts: 40
Location: Dorset, England

PostPosted: Mon Feb 23, 2004 7:16 am Reply with quote

Hi,

All working now Smile It was the missing define ('NUKER',1); that seemed to be stopping it from working.

I've since added the cache code to my scrolling downloads and weblinks blocks, is it worth adding it to blocks that don't change like the modules and donations block?

Anyway, thanks for all your help and hard work, I had tried using JPCache but didn't like the way it worked as when viewing a cached page you would quite often appear to be logged in as someone else Confused

Cheers, Paul K
 
View user's profile Send private message Yahoo Messenger MSN Messenger ICQ Number
steve1
Regular
Regular


Joined: Dec 26, 2003
Posts: 50

PostPosted: Mon Feb 23, 2004 11:49 am Reply with quote

Hi Paul,

Glad it worked. Ok, now moved define('NUKER.. line away from mainfile code to near the top of your root's index.php. That would be ncesssary otherwise when you go into forum admin, you will get an error.

In hindsight, I should have provided better instructions.

steve
 
View user's profile Send private message
Paul_K
PostPosted: Wed Feb 25, 2004 12:50 pm Reply with quote

Hi,

I moved that line straight after I got it all working, I've since gone on to cache most of the blocks and have page generation down to a reasonable time, combined with getting Gzip working it's like I now have a diferent site Smile

Quote:
mine is always DeepBlue, so I hard-coded the function to just always return that.... i.e. I put return("DeepBlue") as the first line in the function. If you allow your users to change themes, your situation would be different (most sites don't, I believe).


I only use one theme, is it just a case of removing all but the line return ("theme") from the get theme function?

Cheers, Paul K
 
steve1
PostPosted: Wed Feb 25, 2004 1:40 pm Reply with quote

Paul, always good when someone can benefit from your work Very Happy

Yes, make the first line in the function say
Code:
return("mytheme");


and you can either remove the rest of the function lines, or just leave it in (I leave it in just in case...).

Pls make sure you have proper capitalization on the theme: Mine is "DeepBlue"

steve
 
Paul_K
PostPosted: Wed Feb 25, 2004 1:44 pm Reply with quote

Hi Steve,

Thanks for the reply, I have found out before (the hard way!) about the importance of correct capitalization on Nuke folders and files Sad

I'm feeling brave tonight so I'm off to try your forum mods... Wish me luck Wink

Cheers, Paul K
 
steve1
PostPosted: Wed Feb 25, 2004 1:53 pm Reply with quote

Great luck, Paul, and I am sure you will make a backup first! Cool Cool Cool Cool Cool
 
Paul_K
PostPosted: Thu Feb 26, 2004 9:20 am Reply with quote

steve1 wrote:
As discussed before, you would want to cache users info:::

open html\modules\forums\index.php

Replace the code (you can figure out what I am talking about) Very Happy
Code:
//steve - use cache to increase performance

if ($CacheData = $Cache_Lite->get($_SERVER['SERVER_NAME'] . 'stats')) {  //make it unique to each webserver address, to not interfere
     $CacheData = unserialize($CacheData);
     $total_posts = $CacheData[0];
     $total_users = $CacheData[1];
     $newest_userdata = $CacheData[2];
}
else {
   $total_posts = get_db_stat('postcount');
   $total_users = get_db_stat('usercount');
   $newest_userdata = get_db_stat('newestuser');
   
   $CacheData = array($total_posts, $total_users, $newest_userdata);
   $Cache_Lite->save(serialize($CacheData));
}


Wink


Me again Laughing I tried doing this modification to my site last night but ran into a problem Sad Probably just me getting something obvious wrong though?

I used the code above to replace this section of code in my index.php

Code:
$total_posts = get_db_stat('postcount');

$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];


So far so good?? Once modified file uploaded to the server I get this error..

Quote:
Fatal error: Call to a member function on a non-object in /home/paulk/public_html/dev/modules/Forums/index.php on line 127


Any pointers on where I went wrong? I tried it a couple of times but it still didn't work, I'm thinking I replaced the wrong code Embarassed

Cheers, Paul K
 
steve1
PostPosted: Thu Feb 26, 2004 10:18 am Reply with quote

Paul, this code assumes that your cache is already set up (via the code snippet starting with NUKER... which I believe you have done).

Now I see that you are replacing 5 lines. Try to replace only these lines, as they appear in my code, not the other two lines.

$total_posts = get_db_stat('postcount');
$total_users = get_db_stat('usercount');
$newest_userdata = get_db_stat('newestuser');

After you do this, and if you get the error again, use an editor that shows line#'s to tell me what is the code corresponding to the error).

steve
 
Paul_K
PostPosted: Thu Feb 26, 2004 10:31 am Reply with quote

Hi Steve,

Ok, I modded my original code so it now looks like this:
Code:
//

// If you don't use these stats on your index you may want to consider
// removing them
//

//steve - use cache to increase performance
if ($CacheData = $Cache_Lite->get($_SERVER['SERVER_NAME'] . 'stats')) {  //make it unique to each webserver address, to not interfere
     $CacheData = unserialize($CacheData);
     $total_posts = $CacheData[0];
     $total_users = $CacheData[1];
     $newest_userdata = $CacheData[2];
}
else {
   $total_posts = get_db_stat('postcount');
   $total_users = get_db_stat('usercount');
   $newest_userdata = get_db_stat('newestuser');
   
   $CacheData = array($total_posts, $total_users, $newest_userdata);
   $Cache_Lite->save(serialize($CacheData));
}
$newest_user = $newest_userdata['username'];
$newest_uid = $newest_userdata['user_id'];


Is that what you meant about not replacing the other two lines? Above code gives an error on line 128 which is...

Code:
if ($CacheData = $Cache_Lite->get($_SERVER['SERVER_NAME'] . 'stats')) {  //make it unique to each webserver address, to not interfere


My cache *appears* to be fine. Files appear in the /includes/Cache_Lite/temp/ directory andare never older than ten minutes so I'm assuming that's ok. I still think it's something stupid I've done! lol

Cheers, Paul K
 
steve1
PostPosted: Thu Feb 26, 2004 11:00 am Reply with quote

ok, you did the first part right. Now somehow your cache is not initializing properly (the stuff in mainfile.php).

So we can try this. Just before the code that you just changed, initialize a new instance of cache::
Code:
   require_once("./includes/Cache/Lite.php"); 

   $options = array( 'cacheDir' => './includes/Cache/temp/','lifeTime' => 600 );
   $Cache_LiteNEW = new Cache_Lite($options);   


Notice the new instance of cache is called $Cache_LiteNEW. Now fix the code you just changed to also say $Cache_LiteNEW wherever you find $Cache_Lite. So in summary, we are initializing cachelite just before caching the user stuff. See if this works. If it works, just leave it.

steve
 
Paul_K
PostPosted: Thu Feb 26, 2004 11:07 am Reply with quote

Hi,

That seems to have sorted it out Smile Any idea why the cache would not be initializing properly using your original code? Just sems a bit weird (I still think I messed it up!)

Cheers, Paul K
 
steve1
PostPosted: Thu Feb 26, 2004 11:19 am Reply with quote

good. I don't know why since I don't have this problem. You can test if your old cache was initialized just before your user code snippet by putting in something like this:

Code:


if (isset($Cache_Lite)) {
echo "cache is good<br>";
}
else {
echo "cache is bad<br>";
}


***also, you may consider using another temp directory for this new cache. I don't know how well written is the Lite code, but we want to avoid any claches between the files of the two cache objects (just in case) Smile
 
southern
Client


Joined: Jan 29, 2004
Posts: 591
Location: Texas

PostPosted: Fri Mar 05, 2004 1:48 pm Reply with quote

Raven wrote:
I'd like you to run some benchmarks on your own site. Repeatedly call your home page, for instance, as it is now written. Maybe 10 times and record the build times. Then, replace the 4 functions with these and run the same test, discarding the first one because if you are using an optimizer, it will recache it the first time when it detects a change.



Here are my results. Allowing for network traffic that I can't control:

Page Generation: before tweaks
1. 1.782 Seconds
2. 1.148 Seconds
3. 12.80 Seconds
4. 1.540 Seconds
5. 1.057 Seconds
6. 1.760 Seconds
7. 1.406 Seconds
8. 2.482 Seconds
9. 1.788 Seconds
10. 1.990 Seconds

Page Generation: after tweaks
1. 1.309 Seconds
2. 0.892 Seconds
3. 1.093 Seconds
4. 0.921 Seconds
5. 1.004 Seconds
6. 0.940 Seconds
7. 1.768 Seconds
8. 1.484 Seconds
9. 0.895 Seconds
10. 0.899 Seconds

There seems a marginal gain in page loading speed but there are too many variables at work on the Internet for me to be sure. Anyway, I'm happy to contribute to scientific progress!
 
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number
MickP
Hangin' Around


Joined: Sep 17, 2003
Posts: 31
Location: Australia

PostPosted: Fri Mar 12, 2004 12:07 am Reply with quote

Quote:
Raven wrote:
I'd like you to run some benchmarks on your own site. Repeatedly call your home page, for instance, as it is now written. Maybe 10 times and record the build times. Then, replace the 4 functions with these and run the same test, discarding the first one because if you are using an optimizer, it will recache it the first time when it detects a change.


Ok, I applied these 4 functions to my very modified site, and also added cache-lite to the blocks, just for information, here are my before and after times for a large index page:

Before any changes:

Page Generation: 6.831 Seconds. - 124 pages served in past 5 minutes.
Page Generation: 3.323 Seconds. - 126 pages served in past 5 minutes.
Page Generation: 3.450 Seconds. - 116 pages served in past 5 minutes.
Page Generation: 2.530 Seconds. - 117 pages served in past 5 minutes.
Page Generation: 6.028 Seconds. - 129 pages served in past 5 minutes.
Page Generation: 7.652 Seconds. - 116 pages served in past 5 minutes.
Page Generation: 4.713 Seconds. - 121 pages served in past 5 minutes.
Page Generation: 3.680 Seconds. - 119 pages served in past 5 minutes.
Page Generation: 4.410 Seconds. - 115 pages served in past 5 minutes.
Page Generation: 6.593 Seconds. - 121 pages served in past 5 minutes.

and after:

Page Generation: 1.216 Seconds. - 165 pages served in past 5 minutes.
Page Generation: 1.083 Seconds. - 164 pages served in past 5 minutes.
Page Generation: 2.718 Seconds. - 166 pages served in past 5 minutes.
Page Generation: 2.553 Seconds. - 167 pages served in past 5 minutes.
Page Generation: 0.926 Seconds. - 175 pages served in past 5 minutes.
Page Generation: 1.674 Seconds. - 174 pages served in past 5 minutes.
Page Generation: 0.862 Seconds. - 177 pages served in past 5 minutes.
Page Generation: 3.380 Seconds. - 171 pages served in past 5 minutes.
Page Generation: 1.181 Seconds. - 171 pages served in past 5 minutes.
Page Generation: 1.068 Seconds. - 151 pages served in past 5 minutes.

I would say it is quite an improvement. I have 7 blocks cached, and ranging in intevals from 1 minute to 2 1/2 hours, depending on the blocks content. (I did not cache the site-visitors block at all either) I have not done the forum changes for cache lite as yet, as they seem to be fine with just the blocks done (av. of 0.4 seconds).

Great idea this one !
 
View user's profile Send private message Visit poster's website
steve1
PostPosted: Fri Mar 12, 2004 12:24 am Reply with quote

Hi, Mick
I would say that is a nice improvement Very Happy I think even more can be gained by using mmcache, which is in-memory cache (cachelite is disk based) and which also caches php code.

My dev environment is Windows, and it does not seem that easy to install mmcache, but I am trying. If anyone figures that out, let me know.
 
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17077

PostPosted: Fri Mar 12, 2004 12:25 am Reply with quote

Great! I had a problem with the Cache Lite and had to remove it until I get time to figure it out. In my site navigation block, after an hour or so, the admin modules would no longer show. Strangest thing.
 
View user's profile Send private message
MickP
PostPosted: Fri Mar 12, 2004 12:34 am Reply with quote

Raven wrote:
Great! I had a problem with the Cache Lite and had to remove it until I get time to figure it out. In my site navigation block, after an hour or so, the admin modules would no longer show. Strangest thing.

Yes, it has taken me about 2 days to get cache-lite to work, but finally did, and it was as simple of changing a few permissions and ownerships here and there (but nothing that should affect security I am hoping)

I use the sommaire block for the menu, but also modified this a lot to my liking as well, and it only shows the admin invis/inactive modules when I am in the admin section, and it is only also visible to myself, all other admins do not see it (yet another hack, due to the way I have the site set up for admins, long story!), other than that, have not found a problem, except when i tested it on the site visitors/info block, and it cached other members details Shocked , so I removed it from that block.

I have looked at mmcache, but thought it was above my level of competancy Crying or Very sad and i would more likely break something Rolling Eyes

Anyways, thanks to all who worked on this, it is great.


EDIT:
hmmm, I see what you mean, overnight my invis and inactive modules disappeared as well, but i guess it is due to the caching. I will overcome this by making a new block just for these tho, visible only to superadmins.
 
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 ©