G-Loaded Forums » WordPress Support

infinite rebuild request

  • Started 9 months ago by randompage

  1. randompage
    Member

    hi,

    i just trying to implement fast static feed wp plugin and found that it broke my server. after checking to the server-status, i found that there is plenty of cache rebuild request, indicated by url var "?force_feed_generation=yes"

    so i did small mod to the plugin on 2 functions:

    `function fsf_auto_create_static_feed() {
    global $FSF_STRIP_COMMENTS, $FSF_FORCE_GEN_ARG;
    global $FSF_FEED_URIs, $FSF_CACHE_DIR;

    fsf_check_cache_dir();
    update_option($FSF_FORCE_GEN_ARG, '1');

    foreach ($FSF_FEED_URIs as $feed_uri) {
    // An extra argument is added (force_feed_generation=yes)
    // This is used in order to avoid looping on the cached XML data
    // when fresh feed content is needed to be fetched.
    $extra_arg = "?".$FSF_FORCE_GEN_ARG."=yes";
    // Read the feed
    $rss_web = fopen(get_option("siteurl") . $feed_uri . $extra_arg, "r");
    $xml_dump = "";
    if ($rss_web) {
    while ( !feof($rss_web) ) {
    $line = fgets($rss_web, 4096);
    // Strips the extra argument in case it is used in any url that is generated by WP
    $line = str_replace($extra_arg, "", $line);
    if (!$FSF_STRIP_COMMENTS or !strpos($line, "wfw:commentRss")) {
    $xml_dump .= $line;
    }
    }
    }
    fclose($rss_web);
    // Dump to file
    $rss_dump = fopen(fsf_feed_uri2path($feed_uri), "w");
    fwrite($rss_dump, $xml_dump);
    fclose($rss_dump);
    }

    delete_option($FSF_FORCE_GEN_ARG);
    }

    function fsf_redirect_feeds() {
    global $feed, $FSF_FORCE_GEN_ARG;
    global $wp, $withcomments;

    if ( is_feed()
    && $feed != 'comments-rss2'
    && !is_single()
    && !$wp->query_vars['category_name']
    && !$wp->query_vars['tag']
    && !$wp->query_vars['author_name']
    && !$wp->query_vars['year']
    && ($withcomments != 1)
    && !isset($_GET[$FSF_FORCE_GEN_ARG])
    && !get_option($FSF_FORCE_GEN_ARG)
    ) {
    // fsf_log(print_r($_SERVER, true));
    // fsf_log(print_r($_GET, true));
    fsf_log("Delivering Static Feed: " . $_SERVER["REQUEST_URI"]);
    $feed_dump_path = fsf_feed_name2path($feed);
    //fsf_log($feed_dump_path);
    fsf_send_response($feed_dump_path);
    }

    if ( is_feed() ) { fsf_log("Dynamically generated: " . $_SERVER["REQUEST_URI"]); }
    }
    `

    the idea is simple, just to indicate wordpress that the cache building process is still run, and (for the time being, while still in build) wordpress will use dynamic feed.

    another thing:
    a. i prefer to use another directory, despite of wp-content. in my case i use "cache" folder at wp root.
    i feel saver to make this folder writeable by webserver rather than wp-content.

    b. i use mu-plugins models for all of plugins of my site, i also apply feed static to mu-plugins folder and it worked.
    so you may indicate it in your plugin page or readme that feed static is also support mu-plugins style.

    c. why not put your plugin to wordpress.org plugins area, its a GREAT plugin. let the world know about the plugin.

    best regards,
    dwi.
    Free PDF Manuals

    Posted 9 months ago #

RSS feed for this topic

Reply

You must log in to post.