just remove phase1.php. Or just do the link thing instead of copying the file. you need the functions to be there only once.
just remove phase1.php. Or just do the link thing instead of copying the file. you need the functions to be there only once.
removed phase1, now I get this little bundle of joy:
Cannot redeclare wp_cache_phase2() (previously declared in /home/.../public_html/wp-content/mu-plugins/wp-cache-phase2.php:12) in /home/.../public_html/wp-content/mu-plugins/wp-cache-phase2.php on line 11
I got the same thing on my local test install as well.
Haven't had a chance to look at it in depth yet though.
Recap of steps, as per Quenting:
1)wp-cache-config.php
$cache_path = ABSPATH . 'wp-content/wpcache/'.$blog_id.'/';
if(!is_dir($cache_path)) {
mkdir($cache_path);
}
2) admin.php
if($_SERVER['REQUEST_METHOD']=='POST') {
do_action('my_update_plugin');
}
3) wp-cache-phase2.php
add_action('my_save_widget_order', 'wp_cache_no_postid', 0);
4) Added SK2 workaround (too long to list)
5) defined WP-CACHE, edited config file to true.
6) Added file advanced-cache.php to wp-content, filled with contents of wp-cache-phase1.php
7) Added wp-cache.php, and wp-cache-phase2.php to mu-plugins
Which, produced the redeclare error as noted in the post above.
To me, the error makes no sense.
The phase2 file is only being included one time, and line 12 is a declaration of globals, with the function declared on line 11.
Very strange indeed.
Heh, I have no idea what the deal is with this.
I dumped it, and started over completely.
Went back through, and the only difference was this time I stuck wp-cache.php into mu-plugins, and left the other files in mu-plugins/wp-cache.
You know, come to think of it, that's probably what generated that error above.
Duh. It makes sense now. If it's in mu-plugins it's going to get parsed. So the plugin includes it, and then so does MU.
Sheesh. I need a drink.
ahh but of course. thanks a ton for the fix luna.
Sure.
Now, if I can just figure out why my live site isn't liking it, that would be great.
lol
Heh, back on the back burner for now I guess.
The only thing I can get it to do on my live site is a blank white screen, with an error in the log about an unexpected $end on line 409 of wp-cache.php (which is a blank line).
Guess I'll get into it eventually.
I'd say maybe it's a conflict with APC, but if I remember right Quenting has that running as well.
That's strange luna. I got it to work following your instructions above. The only thing that's bothering me is it seems the plugin breaks the AJAX Comments plugin i'm using from mike smullin.
Other than that I'm not yet noticing a huge speed boost in performance on my domain. But I do get that neat little message in my footer telling me how quickly the dynamic page was served. :)
scratch that, ajax-comments seems to work fine. Woohoo!
Well, s**t on a stick.
I guess I'll have to work with it some more tonight or something.
I hate touching much on a large scale like that when something is live and operational.
don't you have a test site ?
if you have just a test blog, add an if() around the define(WP_CACHE) until it works.
Now, step by step corrections:
1)wp-cache-config.php
$cache_path = ABSPATH . 'wp-content/wpcache/'.$blog_id.'/';
if(!is_dir($cache_path)) {
mkdir($cache_path);
}
This is not going to work because blog_id won't exist in phase 1. Your files will get cached but never served. You need to fetch the blog_name from HTTP_HOST and use that, or tweak a bit more.
2) admin.php
if($_SERVER['REQUEST_METHOD']=='POST') {
do_action('my_update_plugin');
}
3) wp-cache-phase2.php
add_action('my_save_widget_order', 'wp_cache_no_postid', 0);
This need to be the same name in the do_action and add_action. (ie either my_update_plugin or my_save_widget_order). Widgets being a plugin they'll be covered (unless you already use that version where widgets aren't a plugin anymore.
The most simple to avoid the redeclare things is probably as you guessed to leave things in a subdir. I had to tweak things a bit for them to work like that but i can't remember exactly what i did.
I've been running wp_cache for a few days now and not a single problem reported yet. yeah !
quenting, I'm a little bit confused.
In this post http://mu.wordpress.org/forums/topic.php?id=2296&page=2&replies=71#post-30817 you mentioned making the exact same change of:
$cache_path = ABSPATH . 'wp-content/wpcache/'.$blog_id.'/';
if(!is_dir($cache_path)) {
mkdir($cache_path);
}
yet in your above post you said:
This is not going to work because blog_id won't exist in phase 1. Your files will get cached but never served. You need to fetch the blog_name from HTTP_HOST and use that, or tweak a bit more.
So I'm a little bit confused. On my install I have the above listed modification to my wp-cache-config.php file, and it has succeeded in creating folders in the wp-content/wpcache/ folder based on blog_id.
I also get a message in my footer that "the dynamic content was generated in X..seconds."
Other than that, how can I test to see if wp-cache is serving from the cache?
Q, that's the thing.
Of course I have a test site. It works just great. Just when I took the changes live, it hosed up, with some unexpected $end error on a blank line. It was "interesting" to say the least.
Messing with it on only 1 blog is my next step, just haven't been able to do it yet. Maybe later tonight, or tomorrow night. I'm not sure where I can squeeze it in yet.
@ Sul...
If a dynamic page is served (like the first access, or when it is re-cached):
<!-- Dynamic Page Served (once) in 1.104 seconds -->
If it's a cached page, it'll be like this:
<!-- Dynamic Page Served (once) in 1.104 seconds -->
<!-- Cached page served by WP-Cache -->
luna, thanks for clearing that up.
that means that wp-cache is creating the cache but not loading from it. Because at each page load, I get something like the following:
<!-- Dynamic Page Served (once) in 0.511 seconds -->
but never any mention of a cached page served by wp-cache :(
I was wondering what was going on because I hadn't see any drastic speed boost like I had been expecting.
Quenting, do you know what changes I might need to make to get the pages served from cache correctly?
@sul, as i said, the problem is that blog_id doesn't exist in phase1.
I was wrong in the original post you quoted me on, and corrected myself here:
http://mu.wordpress.org/forums/topic.php?id=2296&page=2&replies=74#post-30840
now what i have is something like:
$serv = $_SERVER['HTTP_HOST'];
$vars=explode('.',$serv);
if(sizeof($vars)<1 || strlen($vars[0])==0 || $vars[0]=='unblog') {
$vars[0]='0';
}
$myblogname = $vars[0];
$cache_path = ABSPATH . 'wp-content/wpcache/'.$myblogname.'/';
if(!is_dir($cache_path)) {
mkdir($cache_path);
}
because HTTP_HOST does exist in phase1. So this way your files get served from the cache.
@luna, it's really weird. I've messed my wp-cache version so i don't know what line 409 is, but i haven't seen anything like it. I run APC indeed. The only tweak it needed was taking out the cache files so that they wouldn't be stored in memory (it can quickly make a lot of them and my APC somehow chokes when its memory is full with segfaults).
quenting, thanks a ton for your fix. The above code placed in my wp-config-cache.php file is now producing folders by blog name with the pages being served from wp-cache.
Now I need to go and run my tests again to make sure no other plugins are interfering, but thanks again, been trying to get this bad boy running for a while!
that's the most difficult i think. Figure what's not flushing the cache when it should, and figure what parts of your plugins still needs to be run even when serving the file from cache.
Hmmm...
What did you tweak with APC?
I'm wondering if that wasn't the problem maybe. Although I tend to notice that when APC has a problem, it typically just sent the browser the file to download instead of display.
As for the 409 thing, that was just a reference. It's nothing logical whatsoever.
I will note as well that if I went into the back and into the plugin setting page, that it would be fine if there was some sort of error (like need to chmod or create the cache directory), but once it was OK to use, it cut the page off and stopped rendering at a certain point. Main Options or something like that. It was weird for sure.
If I can get a window to mess with this this morning, I'm going to give it another shot.
> What did you tweak with APC?
not much actually, just excluded "cache" files from parsing.
> I'm wondering if that wasn't the problem maybe. Although I
> tend to notice that when APC has a problem, it typically
> just sent the browser the file to download instead of
> display.
er the blank page is what i used to see myself when having problems with APC. They were mostly the consequence of segfaults. is there anything in your log file ? Do you have php errors turned on ?
There wasn't anything in the error logs other than the premature $end error I mentioned previously.
I did just stick it on a separate site that's on the same box that I had stuck up for a couple of friends, and it works just fine.
So, I'm going to try it one more time, and see what happens.
For APC, I added this to my filter line for cache:
apc.filters = "(class_bbcode_alt.php)|(kses.php)|(-.*cache.*.php)"
Well well well.
As far as I can tell, it's up and running.
Logins appear fine (I have the username printed in the sidebar, with a list of their blogs), and all the other jazz too.
After I had it running on the "friend" site, I was in the middle of transferring files and noted something. On the "friend" site, I never transferred the wp-cache.php plugin file to mu-plugins. I breezed through it real quick, and it's just backend stuff. So, I left it out on my main site and all is well.
That being said, I'm not touching it. Blogs are being cached, cached pages served, and I've even noticed a drop in times when it's creating the initial cache page and serving it dynamic.
Well, guess I'll keep tabs on it for a while and see what happens over the weekend as well. I started a top while I was transferring files to my main site, and have kept it running since. Definitely a noticeable difference when I finally flipped the switch.
Thumbs up Q. ;)
yeah you don't need that file really. I left it with an is_site_admin thing for the menu to appear just for me, but so far i haven't even looked at the page.
If i can sugges something, after playing for a few days with it : the cache seems to be only effective for blogs that receive a minimum of traffic. If you have a whosonline plugin or something to monitor most active blogs, i suggest you activate it at first only, on, like the top X blogs.
For me after making a few tries it appears that the optimal setting is to have the top 70-80 blogs (basically, those which have almost permanently 30+ users online) use the cache and not use it for the others. This is already advanced tweaking, but the cache is basically making things slower on blogs that are not visited much.
I'd thought about that as well.
Essentially if there isn't someone visiting it within the specified cache time, it's never really serving the cached pages and just generating more load overall for that site. Not to mention eating more storage.
For that, I would guess that the WP-CACHE constant would have to be moved from wp-config, to where the blog id is already available, or, have to run a check on the http_host before setting it in wp-config.
I keep a pretty clean tab on unused blogs, like the ones where they login once and that's it, and if they go unused after a couple of weeks I just take em off.
Other than that, the ones I have that are being used usually have at least a couple folks on them at any given point.
I'll have to take a look and see what's what, and play with it a bit. Then just set an array of http_host matches to turn it on for.
that's what i did actually, i have hardcoded arrays of most popular blogs'names for each specific install to see if the WP_CACHE should be defined or not. Quick and dirty, but still somewhat efficient.
Efficient being the key.
Thus far, a few hours later, it's still working well.
I added the plugin file a little bit ago as a test as well. Working fine now, so I dunno what the earlier issue was.
So I'm noticing a problem now where comments are not being updated on blogs that have wp-cache enabled (right now all of them).
I'm wondering what I can do to to get them to appear, since they do once I expire the cache but otherwise they don't, and since my users don't have access to the wp-cache menu, they can't go in and clear the cache themselves to make their comments appear.
I thought the above posted fix for SK2 was dealing with this problem?
The thing fixing it is the specific SK2 plugin called sk2_wp_cache_plugin (or something along this line). Works for me at least. didn't you mention ajax comments though ?
not using ajax comments on this specific blog. What happens is that I can login and leave a comment, but the page doesn't update with my comment until after I flush the cache.
what version of MU do you run ? and sk2 ? did you install the mentionned sk2 plugin ?
« Previous 1 2 3 4 Next »