Hi doconeill,
First problem: if there’s no info on the theme in the URL right now I don’t think there’s a way to solve this. I’m going to think about the topic.
Second problem: if the logged-in pages could be identified by and URL pattern, you could add an exception to nginx, but since nginx is unable to analyze content normally, without a “hacked” nginx, it’s not possibile to diverse this way.
I’ll look deeper how to check for a cookie from nginx, this might solve it.
Ho doconeill,
I’ve extended the nginx part, I’ll test it this week as soon as possible. For the different theme layout, I’d recommend setting up a cookie and somehow insert it into the rewrite uri sent to wordpress.
For tips see this post:
http://nicknotfound.com/2009/01/12/iphone-website-with-nginx/
Thanks for looking in to it. The performance boost by bypassing PHP was nice, but not necessary at the moment. I may need to re-architect for the mobile issue…
Hi @doconeill,
I’ve been testing and appending the nginx sample conf; it seems that serving with nginx from memcached directly can now be used without problems using the following:
upstream memcached-server {
server MEMCACHEDHOST:MEMCACHEDPORT;
keepalive 32;
}
...
server {
...
location @memcached {
default_type text/html;
set $memcached_key DATAPREFIX$scheme://$host$request_uri;
set $memcached_request 1;
# exceptions
# avoid cache serve of POST requests
if ($request_method = POST ) {
set $memcached_request 0;
}
# avoid cache serve of wp-admin-like pages, starting with "wp-"
if ( $uri ~ "/wp-" ) {
set $memcached_request 0;
}
# avoid comment sync caching used for disqus plugin usually
if ( $uri ~* "sync_comments" ) {
set $memcached_request 0;
}
# avoid cache for logged in users
if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_" ) {
set $memcached_request 0;
}
if ( $memcached_request = 1) {
more_set_headers 'X-Cache-Engine: nginx ( with WP-FFPC )';
memcached_pass memcached-server;
error_page 404 = @rewrites;
}
if ( $memcached_request = 0) {
rewrite ^ /index.php$request_uri last;
}
}
## rewrite rules
location @rewrites {
rewrite ^ /index.php$request_uri last;
}
location / {
try_files $uri $uri/ @memcached;
}
...
}
...
replace DATAPREFIX with your data prefix set on options page ( default: data- )
replace MEMCACHEDHOST with your memcached host IP ( default: 127.0.0.1 )
replace MEMCACHEDPORT with your memcached server port ( default: 11211 )
This is going to be part of the next release but I need other stuff to be changed as well, so consider this as pre-release 😉
For the theme problem: you could change the key in the PHP code and the memcached config to include something else as well, depending on a cookie entry existenz for example, but I haven’t figured out anything else yet.
Thanks…I’ll look into these changes and see how it works. Interestingly, I have another site I’ve been setting up and just started working on, and had the old nginx memcached code still active – but I don’t seem to have the same problem with it. Not sure why.
Figured out why I wasn’t seeing the problem on the other site – misconfigured the cache 🙂
This seems to work – after I figured out that a cut-and-paste turned the quotes into entities…also I had to skip more_set_headers for now as I don’t have that module compiled in yet.
Thanks for the help!
Hmm…spent some time looking at this more closely. Although the cache appears to be working, I’m not sure that nginx is using the memcached directly.
I added the module so that I could use more_set_headers, but the header in the config above doesn’t show up. I can put one outside the “location = @memcached” section, and it shows up. If I put it as the first thing inside the section, however, it doesn’t. So it appears that the request is never actually making it to the @memcached section.
I haven’t tracked down why it doesn’t seem to to check it yet. I even put a more_set_headers in the “location /” section, and it doesn’t show up either. But I’m relatively new to nginx and having fun with location specs…here are the only ones I have on the site I’m testing with:
location / {
location @rewrites {
location @memcached {
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
location ~ /wp-admin/.*\.php$ {
location ~ /wp-admin/.*\.php$ { # This is to be able to have unbuffered output while updating plugins, wordpress, etc.
location ~ \.php$ {
location ~* /(?:uploads|files)/.*\.php$ {
location ~ /\.ht {
So I’m not sure why it won’t follow the “location /”…
Hi,
I’ve tried reproducing the bug, but I’m unable to do so.
Do you have any update on the topic?
I was never able to get nginx to use the cache directly. Since then I’ve had to abandon nginx due to a number of unrelated issues getting some sites to work, and have gone back to Apache. Still using it on the PHP side though.
Sad to hear you’re not on nginx anymore, anyway, feel free to get back to me whenever you change your mind.