FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home  »  Optimization  »  Hacking WP Super Cache for Speed

by 11 comments

So I couldn't help it, I downloaded and installed WP Super Cache because it sounded like an ideal setup for me.. A plugin built to generate static files from php+mysql for Apache to serve the way its supposed to be.. My dream.

So I started digging into the code. Its a form of WP Cache-2, but fork is a generous word at this point. There is some future add-on capability, but the code that actually performs the caching is pretty much the same. Bloated, inefficient, and redundant coding. This plugin could do the same thing with 1 file, no config, no meta, serializing, etc.. But its still a lot better than anything I've created.

AskApache Crazy Cache - coming soon

I'm very interested in this technology and this is the closest to my ideal that a WordPress plugin has come so far, I might just start from scratch one of these days, once I figure out a few php bits I'm still learning about. If I do decide to make a caching plugin the right way, it will have similar tricks that I used in the Hack WP-Cache for maximum speed post.


My WP Super Cache .htaccess

The .htaccess generated by WP Super Cache is wack, I'm not even sure how its been working for everyone, I've hacked it up a bit and this is working great for me.. Will definately be updated as I do more debugging.

I used some of the same techniques found here, and here, and these SetEnvIf examples.

# BEGIN WordPress

SetEnv HTTP_IF_GZ_MATCH .html
SetEnvIfNoCase ^Accept-Encoding$ "(.*gzip.*)" HTTP_IF_GZ_MATCH=.html.gz

RewriteCond %{ENV:REDIRECT_STATUS} !=200
RewriteCond %{QUERY_STRING} !s
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+) HTTP/ [NC]
RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|wp-postpass_).*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%1/index%{ENV:HTTP_IF_GZ_MATCH} -f
RewriteRule ^(.*)$ /wp-content/cache/supercache/$1/index%{ENV:HTTP_IF_GZ_MATCH} [L,NC]

# END WordPress

WP Super Cache .htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} !.*s=.*
RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
RewriteCond %{HTTP_COOKIE} !^.*wordpress.*$
RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

RewriteCond %{QUERY_STRING} !.*s=.*
RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
RewriteCond %{HTTP_COOKIE} !^.*wordpress.*$
RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]

# END WordPress

It's definately a complex kind of plugin in that there is a lot of directions and a lot going on, so I'm not saying anything bad about the developers, just hope to see some updates over the next few months so I don't have to mess with it.

Tags

January 30th, 2008

Comments Welcome


Related Articles


My Online Tools
Popular Articles


Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two. See my article, On Hacking.
-- Richard M. Stallman









[hide]

It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | askapache

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service

↑ TOPMain