[wp-hackers] cheap 404 serving

Ryan McCue lists at rotorised.com
Tue Oct 16 11:18:36 UTC 2012


"Matthias P. Würfl" wrote:
> All the rewrite-rules i can find send every request that cannot be
> served as static content to wordpress. It would be cheaper to check the
> request if handeling by wordpress makes sense at all before wordpress is
> bootstrapped.
> 
> - URL ends on ".html" or "/"

Both of these can be used by WordPress (especially ending with a
trailing slash, which most sites use). If you don't use them in your
site, it should be fairly trivial to not send that to WP.

> - Accept-header contatins "text/html"

All pages requested from WP (with the exception of RSS/Atom feeds and
XML-RPC) will have "Accept: text/html, ...", otherwise the server would
have no idea what to send back. I think you may be misunderstanding what
this header does.

> Are there any ready-to-use recipes to serve 404 errors cheaper? For
> Nginx? :-)

Alright, so as far as I can tell, this breaks down into a few places:

Anything starting with "wp-admin/", "wp-content/" or "wp-includes/" can
be ignored, since WP rewrite rules should never touch those.

Something like this should fix that (for nginx):

	location ~* ^(/wp-includes|/wp-content|/wp-admin) {
		try_files $uri $uri/ =404;
	}

(Assuming you're not using the 404 handler for WordPress; please don't
do that.)

If there's interest in this, I'll write up a longer version with all the
rules I'd put in a site's file for nginx.

-- 
Ryan McCue
<http://ryanmccue.info/>


More information about the wp-hackers mailing list