Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect when XML Sitemap URL does not exist for Auto-Cache Engine #555

Closed
raamdev opened this issue Aug 21, 2015 · 9 comments
Closed

Detect when XML Sitemap URL does not exist for Auto-Cache Engine #555

raamdev opened this issue Aug 21, 2015 · 9 comments

Comments

@raamdev
Copy link
Contributor

raamdev commented Aug 21, 2015

Forked from #512 (comment)

@jaswsinc writes...

So you were not running a plugin that generates a sitemap at all in this case. WordPress doesn't generate an XML sitemap automatically, so without a sitemap plugin this URL should in fact return a 404 error; i.e., that would be expected.

http://192.168.2.14/webby/sitemap.xml = 404 (expected in a default install)

It sounds like you enabled the ACE in ZenCache, and perhaps entered your own list of URLs instead of relying on the sitemap alone. Do I have that right?

If you leave the ACE configured with /sitemap.xml as a config. option (that's a default value), then it will still look for that sitemap location too, in addition to any other URLs that you enter manually.

↑ That could trigger the 404 error, and I can see where that would lead to this confusion.

2015-08-21_06-57-58

@raamdev
Copy link
Contributor Author

raamdev commented Aug 21, 2015

@jaswsinc I think we can do better than a note: We should just check the XML Sitemap URL and see if it returns the appropriate status code. If it does not, we show a warning message indicating that the XML Sitemap could not be found and suggest installing the Google XML Sitemaps plugin, or clear the XML sitemap field and use the list of URLs instead. (Bonus points if we can also validate that a valid XML Sitemap exists at the URL when then URL returns an non-404.)

@jaswrks
Copy link

jaswrks commented Aug 25, 2015

👍

@jaswrks
Copy link

jaswrks commented Oct 7, 2015

Next Actions

  • New feature branch: feature/555 in the websharks/zencache-pro repo.

  • Replace these lines of code with the following:

    if (is_wp_error($head = wp_remote_head($sitemap, array('redirection' => 5)))
          || empty($head['response']['code']) || (integer) $head['response']['code'] >= 400
          || empty($head['headers']['content-type']) || stripos($head['headers']['content-type'], 'xml') === false) {
    
            // Enqueue a dashboard notice if this is a primary Sitemap location.
            if (!$___recursive) { // Fail silently on recursive calls.
                $this->plugin->enqueueMainNotice(
                    sprintf(__('<strong>%1$s says...</strong> The Auto-Cache Engine is currently configured with an XML Sitemap location that could not be found. We suggest that you install the <a href="http://zencache.com/r/google-xml-sitemaps-plugin/" target="_blank">Google XML Sitemaps</a> plugin. Or, empty the XML Sitemap field and only use the list of URLs instead. See: <strong>Dashboard → %1$s → Auto-Cache Engine → XML Sitemap URL</strong> ', SLUG_TD), esc_html(NAME)),
                    array('class' => 'error', 'persistent_key' => 'xml_sitemap_missing')
                );
            }
            goto finale; // Nothing more we can do in this case.
    }
  • Submit PR.

@jaswrks
Copy link

jaswrks commented Oct 7, 2015

@kristineds While working on this issue you can learn more about is_wp_error() and the WP_Error class here: https://codex.wordpress.org/Function_Reference/is_wp_error

kristineds pushed a commit to wpsharks/comet-cache-pro that referenced this issue Oct 7, 2015
@raamdev raamdev added this to the Next Release (Pro) milestone Oct 7, 2015
@raamdev
Copy link
Contributor Author

raamdev commented Oct 8, 2015

Next Pro Release Changelog:

  • Enhancement: The Auto-Cache Engine now detects when the configured XML Sitemap is not valid or is unreachable and displays an appropriate notice. Props @kristineds and @jaswsinc. See Issue #555.

@raamdev raamdev closed this as completed Oct 8, 2015
@KTS915
Copy link

KTS915 commented Nov 5, 2015

@raamdev, @kristineds, @jaswsinc,

This is a great new addition. (I am just trying out the new RC.) Thank you! I had enabled this before without realizing that I need to use a plugin to create an xml sitemap.

I have now installed Simple Wp Sitemap (https://wordpress.org/support/plugin/simple-wp-sitemap) and it seems to be doing the job (without pinging Google, which other sitemap plugins do, and which I don't want).

But now I have a question. This plugin allows me to add other pages outside WordPress (e.g. static html files) to the sitemap. If I do this, does it mean that ZenCache Pro will then be able to cache them too?

@jaswrks
Copy link

jaswrks commented Nov 7, 2015

I have now installed Simple Wp Sitemap (https://wordpress.org/support/plugin/simple-wp-sitemap) and it seems to be doing the job (without pinging Google, which other sitemap plugins do, and which I don't want).

Nice! Thanks for the link. I'll bookmark that one.

But now I have a question. This plugin allows me to add other pages outside WordPress (e.g. static html files) to the sitemap. If I do this, does it mean that ZenCache Pro will then be able to cache them too?

I'm afraid not. If it's in the sitemap, ZenCache may attempt to load that page and cache it, but that attempt will fail gracefully since WordPress and ZenCache are not actually loaded in static HTML files.

@KTS915
Copy link

KTS915 commented Nov 7, 2015

@jaswsinc,

That's what I suspected. Thanks for the explanation!

@raamdev
Copy link
Contributor Author

raamdev commented Nov 14, 2015

ZenCache v151114 has been released and includes changes from this GitHub Issue. See the v151114 announcement for further details.


This issue will now be locked to further updates. If you have something to add related to this GitHub Issue, please open a new GitHub Issue and reference this one (#555).

@wpsharks wpsharks locked and limited conversation to collaborators Nov 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants