Welcome! Log In Create A New Profile

Advanced

Re: wordpress 3.0 wp super cache rewrite rule?

August 05, 2010 11:51AM
Piotr Karbowski Wrote:
-------------------------------------------------------
> On 04.08.2010 12:06, Max wrote:
> > Hi Piotr,
> >
> > Thanks. I tried your rewrite rule, but it seems
> it doesn't work with
> > multisite. I can't see any cache page generated.
>
> You need change something in wp-super-cache for MU
> if I remember correct
> (check readme.txt).
>
> > Your rewrite rule is interesing, so simple, but
> as long as it get thing
> > done, it's ok. I used to use the following rule
> to make the permalinks
> > works.
> >
> > rewrite ^.*/files/(.*)$
> /wp-includes/ms-files.php?file=$1 last;
> > if (!-e $request_filename) {
> > rewrite ^.+?(/wp-.*) $1 last;
> > rewrite ^.+?(/.*\.php)$ $1 last;
> > rewrite ^ /index.php last;
> > }
>
> Well I not fully understand your 2nd rule, with !
> -e but it is working?
> You rewritting all requests targeted to
> non-existing files to 3 others
> thing? Last rewrite doing the same thing what
> nginx's try_files.
>
> I have on the end of my blog (generated page):
>
> <!-- Dynamic page generated in 0.107 seconds. -->
> <!-- Cached page generated by WP-Super-Cache on
> 2010-08-04 18:55:06 -->
> <!-- Compression = gzip -->
>
> So it's working for me.
>
> -- Piotr.
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://nginx.org/mailman/listinfo/nginx

Except you're only getting half the benefit of wp-super-cache because you're serving the cached file through php.

To serve the cached file directly through nginx without touching the php backend, try something like this:

server {
listen 192.168.1.102:80;
server_name wordpress-cache
mydomain.com;
access_log /var/log/nginx/$host.access.log;
root /var/www/wordpress_dir;
server_name_in_redirect off;
index index.php;

location / {
if ($request_uri ~ ^.*//.*$) {
return 405;
}
if ($request_method ~ POST) {
return 405;
}
if ($query_string ~ ^.*=.*$) {
return 405;
}
if ($http_cookie ~ (comment_author_|wordpress_logged_in|wp-postpass_)) {
return 405;
}
if ($http_x_wap_profile ~ ^[a-z0-9\"]+) {
return 405;
}
if ($http_profile ~ ^[a-z0-9\"]+) {
return 405;
}
if ($http_user_agent ~ ^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|Googlebot-Mobile|hiptop|IEMobile|KYOCERA/WX310K|LG/U990|MIDP-2.|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|PlayStation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|SHG-i900|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|webOS|Windows\ CE|WinWAP|YahooSeeker/M1A1-R2D2|iPhone|iPod|Android|BlackBerry9530|LG-TU915\ Obigo|LGE\ VX|webOS|Nokia5800).*) {
return 405;
}
if ($http_user_agent ~ ^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|doco|eric|hipt|htc_|inno|ipaq|ipod|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-|lg/u|maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|palm|pana|pant|phil|play|port|prox|qwap|sage|sams|sany|sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo|teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|wap-|wapa|wapi|wapp|wapr|webc|winw|winw|xda\ |xda-).*) {
return 405;
}
error_page 405 = @nocache;

expires epoch;
add_header Vary "Cookie";
add_header Cache-Control "store, must-revalidate, post-check=0, pre-check=0";
charset utf-8;

try_files /wp-content/cache/supercache/${host}${uri}index.html $uri $uri/ /index.php?q=$uri&$args;
}

location @nocache {
try_files $uri $uri/ /index.php?q=$uri&$args;
}

location ~ ^.*\.php$ {
try_files $uri @nocache;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/t7.brianmercer.com/public$fastcgi_script_name;
fastcgi_pass php;
}

location ~ ^.+\.(jpg|jpeg|gif|png|ico|css|js)$ {
access_log off;
expires 45d;
}

location = /favicon.ico {
try_files /favicon.ico =204;
}
}

If you have the gzip_static module compiled in and compression turned on in wp-super-cache, then nginx will serve the index.html.gz file directly.

I'm still trying to work out a good multi-site version. Wordpress's multi-site implementation makes me appreciate how well Drupal does multisite.
Subject Author Posted

wordpress 3.0 wp super cache rewrite rule?

Max August 03, 2010 06:38AM

Re: wordpress 3.0 wp super cache rewrite rule?

Piotr Karbowski August 04, 2010 05:06AM

Re: wordpress 3.0 wp super cache rewrite rule?

Max August 04, 2010 06:12AM

Re: wordpress 3.0 wp super cache rewrite rule?

Piotr Karbowski August 04, 2010 06:52PM

Re: wordpress 3.0 wp super cache rewrite rule?

brianmercer August 05, 2010 11:51AM

Re: wordpress 3.0 wp super cache rewrite rule?

brianmercer August 05, 2010 11:58AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 86
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready