Author |
Message |
telli
New Member


Joined: Sep 24, 2003
Posts: 21
|
Posted:
Mon Feb 23, 2004 12:44 am |
|
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  |
|
|
|
 |
Paul_K
Hangin' Around

Joined: Feb 22, 2004
Posts: 40
Location: Dorset, England
|
Posted:
Mon Feb 23, 2004 7:16 am |
|
Hi,
All working now 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
Cheers, Paul K |
|
|
 |
 |
steve1
Regular


Joined: Dec 26, 2003
Posts: 50
|
Posted:
Mon Feb 23, 2004 11:49 am |
|
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 |
|
|
|
 |
Paul_K

|
Posted:
Wed Feb 25, 2004 12:50 pm |
|
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
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

|
Posted:
Wed Feb 25, 2004 1:40 pm |
|
Paul, always good when someone can benefit from your work
Yes, make the first line in the function say
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

|
Posted:
Wed Feb 25, 2004 1:44 pm |
|
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
I'm feeling brave tonight so I'm off to try your forum mods... Wish me luck
Cheers, Paul K |
|
|
|
 |
steve1

|
Posted:
Wed Feb 25, 2004 1:53 pm |
|
Great luck, Paul, and I am sure you will make a backup first!  |
|
|
|
 |
Paul_K

|
Posted:
Thu Feb 26, 2004 9:20 am |
|
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)
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));
}
|
|
Me again I tried doing this modification to my site last night but ran into a problem 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
Cheers, Paul K |
|
|
|
 |
steve1

|
Posted:
Thu Feb 26, 2004 10:18 am |
|
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

|
Posted:
Thu Feb 26, 2004 10:31 am |
|
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

|
Posted:
Thu Feb 26, 2004 11:00 am |
|
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

|
Posted:
Thu Feb 26, 2004 11:07 am |
|
Hi,
That seems to have sorted it out 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

|
Posted:
Thu Feb 26, 2004 11:19 am |
|
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)  |
|
|
|
 |
southern
Client

Joined: Jan 29, 2004
Posts: 624
|
Posted:
Fri Mar 05, 2004 1:48 pm |
|
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! |
|
|
|
 |
MickP
Hangin' Around

Joined: Sep 17, 2003
Posts: 31
Location: Australia
|
Posted:
Fri Mar 12, 2004 12:07 am |
|
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 ! |
|
|
|
 |
steve1

|
Posted:
Fri Mar 12, 2004 12:24 am |
|
Hi, Mick
I would say that is a nice improvement 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: 17088
|
Posted:
Fri Mar 12, 2004 12:25 am |
|
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. |
|
|
|
 |
MickP

|
Posted:
Fri Mar 12, 2004 12:34 am |
|
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 , so I removed it from that block.
I have looked at mmcache, but thought it was above my level of competancy and i would more likely break something
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. |
|
|
|
 |
|