• I think supercache used to disk-cache RSS feeds, but that stopped working somewhere in the last 5 years ago or so, and I saw a message from Donncha a while ago that it isn’t supposed to work any more, but just uses the legacy wp-cache.

    I have a site whose RSS feeds are the most popular part of the site, and so caching those greatly improves performance, so I worked on getting it to work tonight.

    Here’s how I did it:

    Modifications to .htaccess:

    # special case for RSS feeds
    RewriteCond %{HTTP:Cookie} !^.*(wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/feed.xml -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/feed.xml" [L]
    </IfModule>

    (I left the logged_in and postpass part there – the postpass probably doesn’t make any sense, but I thought logged in people might like to see the most recent version, and this site doesn’t have lots of logins, other than the administrators).

    Then, I made a shell script:

    #!/bin/bash
    
    # delete and recreate supercache feeds
    
    SITE="http://www.example.com/"
    
    SUPERCACHE_DIR="/home/example/wp-content/cache/supercache/www.example.com/"
    
    FEEDS="feed/ feed/podcast/"
    
    INDEX_FILE="feed.xml"
    
    ############### STOP EDITS #############
    
    TEMP_FILE=<code>mktemp</code>
    
    for feed in $FEEDS; do
            file="${SUPERCACHE_DIR}${feed}${INDEX_FILE}"
            rm $file &> /dev/null
            wget -qO $TEMP_FILE $SITE$feed
            if [ $? == 0 ] ; then
                    chmod a+r $TEMP_FILE
                    mv $TEMP_FILE $file
            fi
    done

    And then added a cronjob to run this script every 15 minutes:
    */15 * * * * /home/example/bin/generate_feeds.sh

    I originally had some mime-type stuff in an .htaccess file to set ForceType to text/xml, but I removed it because the apache server was already doing the right thing without that.

    Tada. Server load dropped by 60%!

    https://ww.wp.xz.cn/plugins/wp-super-cache/

The topic ‘RSS feed disk-based caching’ is closed to new replies.