• I have a script that disables my index.php (chmod 000) when the cpu load is high, but I’d like to change my .htaccess to have it serve a super cached file (if it exists). Of course if index.php has 644 permissions it shows the cached page as supposed to. But if I chmod it to 0 then no redirects are made.

    As you can guess I don’t exactly understand WP-SuperCache’s .htaccess entries.

    Any ideas?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Why not run supercache all the time? Unfortunately you’ll have to learn about those .htaccess rules! Or just have your script replace the stock .htaccess with one with the supercache rules when the load gets high.

    Thread Starter matia

    (@matia)

    First of all thank you very much for replying ??

    I already have SuperCache running with it’s own .htaccess rules (copy pasted from the plugin options) and it does serve super cached files

    (from a file’s source code:
    <!– Dynamic page generated in 0.406 seconds. –>
    <!– Cached page generated by WP-Super-Cache on 2009-10-17 12:26:19 –>
    <!– Compression = gzip –>
    )

    But if index.php has 0000 perms, then a super cached file cannot be served. So I’m guessing that index.php is in the way (well in a way that doesn’t help me ;P )

    Thread Starter matia

    (@matia)

    my .htaccess

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP_USER_AGENT} !^.*(Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*
    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 %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP_USER_AGENT} !^.*(Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile|iPhone|iPod|KYOCERA/WX310K|LG/U990|MIDP-2.0|MMEF20|MOT-V|NetFront|Newt|Nintendo\ Wii|Nitro|Nokia|Opera\ Mini|Palm|Playstation\ Portable|portalmmm|Proxinet|ProxiNet|SHARP-TQ-GX10|Small|SonyEricsson|Symbian\ OS|SymbianOS|TS21i-10|UP.Browser|UP.Link|Windows\ CE|WinWAP).*
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
    </IfModule>
    
    # END WPSuperCache
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Could my “problem” be in the WP part of the .htaccess and not in the WPSuperCache rules?

    Thread Starter matia

    (@matia)

    My other idea is to move myblog.domain.com (WP) to myblog2.domain.com
    have a copy of all the supercached files in myblog (which is known to google) and have a .htaccess that would redirect a 404 error to myblog2 (which would be running my WP)

    really static has a similar concept but 1) I don’t want to ftp all my posts etc and 2) it doesn’t want to co-operate with any ftp server I’ve tried

    I think however there must be a neat .htaccess way to do show the super cached file even if index.php of WP is chmoded 0.

    Thread Starter matia

    (@matia)

    anyone?

    Thread Starter matia

    (@matia)

    I’ve tried nginx and got the same problem

    Just read

    https://techblog.evo.pl/en/2009/03/21/how-to-boost-speed-up-your-typo3-website-with-nginx/

    let me quote a phrase

    “in order to read cache, one has to invoke a php process, read and parse the cached data, and then send the information to the browser.”

    If mod_rewrite rules are execute then it should bypass your index.php. There’s no need to run any php code when mod_rewrite handles the request and serves the data from the supercache drectory.

    Thread Starter matia

    (@matia)

    I’m trying to point out that both in apache and nginx the web server’s rewrites are overriden by php.

    But the rewrites don’t work as supposed to and you can test and check that by chmoddin 0 the index.php on a WP installation.

    Thread Starter matia

    (@matia)

    I think that the .htaccess rules that SuperCache suggest needs some modifications to work the way we both wish.

    No, I just tried chmod 0 index.php on my own server and it served the front page from the supercache static files without executing any PHP.

    The plugin is probably not installed correctly on your server and only working in half-on mode or something.

    Thread Starter matia

    (@matia)

    I was really convinced because I tried it on two different machines, one with apache and the other with nginx. Thank you for checking it yourself, I ‘l have to “dig” deeper into my setup I guess :”)

    bartoszx

    (@bartoszx)

    Try to run nginx + memcached as described here https://techblog.evo.pl/en/2009/03/21/how-to-boost-speed-up-your-typo3-website-with-nginx/

    Above shows how TYPO3 is powered by nginx but you can adopt it to your needs. Model is very simple. Your application writes data to memcached and Nginx read directly from memcached. This is very fast and efficient way. You can also configure nginx to bypass memcached if request is POST or match each custom urls.

    I am not wordpres expert but I am sure that wordpres can write data do memched also.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Plugin: WP Super Cache] understanding mod rewrite (skipping index.php)’ is closed to new replies.