WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Feature request:: Test for opening XML tag in wp_cache_get_ob() (4 posts)

  1. John Blackbourn
    Member
    Posted 2 years ago #

    A plugin of mine outputs content in XML format. WP Super Cache isn't caching these pages because they don't contain the HTML/RSS elements which are tested for.

    WP Super Cache's wp_cache_get_ob() function tests for the existence of closing html, rss, feed and urlset tags to determine whether Super Cache should cache the page. My XML pages have none of these, so Super Cache doesn't cache them. The pages do have a proper XML header which starts with <?xml. It would be great if Super Cache could also check for the existence of this tag to determine if the page should be cached.

    W3 Total Cache happily caches these pages as it checks for <?xml among other things.

    Here's the required change to the regex in wp_cache_get_ob():

    /(<\/html>|<\/rss>|<\/feed>|<\/urlset|<\?xml)/i

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    But what tag goes at the end? </xml> ? That's the tag that should be checked for as the plugin might try to save an incomplete page.

  3. John Blackbourn
    Member
    Posted 2 years ago #

    Unfortunately there isn't a closing </xml> tag at the end of an XML document. There's just the closing tag for whichever container element is used, eg </rss>, </data> or </whatever>.

    Good point about incomplete pages. The plugin could instead look for the first opening tag and then check there's a matching closing tag. You wouldn't need the individual rules for /html, /rss, /feed and /urlset then and all situations would be covered.

  4. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Ah, I remember that now from previous conversations about this. That's why urlset is in there!

    I think I'll add a filter on that list. I don't want to go parsing the html of a page finding the first tag and the corresponding tag. A filter will allow this problem to be avoided by those who are working in this space. It'll be in the next version.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic