BoldGrid / w3-total-cache

GNU General Public License v2.0
152 stars 85 forks source link

W3TC should also support sitemap.txt to ease learning and debugging #683

Closed porg closed 4 months ago

porg commented 1 year ago

For learning/debugging the Cache Preload cycle, working with a plain text sitemap.txt would be so much easier. Please support this in W3TC!

Reasoning

This has official backing! Because the official SiteMap specification under Other Formats lists Text File as a valid option:

You can provide a simple text file that contains one URL per line.

Minimal sitemaps (URL only) in TXT or XML format are essentially the same

Short video loop showing that a minimal sitemap is essentially the same in the TXT and XML formats

Because in the XML tag definitions it is clearly stated that per <url> tag the only mandatory tag is a <loc> tag. Which is essentially the same as a plain text sitemap with one URL per line.

In your plain text:

FIND:              (.*)
REPLACE:  <url><loc>$1</loc></url>

At file start insert:

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">

At file end insert:

</urlset>

Change the file extension from TXT to XML.

Et Voila: You have a valid XML sitemap. Mine validated positive.

In the learning/debugging session which by itself is anyhow unnerving admins sure would be happy to spare themselves that extra conversion effort and just work with a simple one URL per line sitemap.txt

What do you say?

cssjoe commented 4 months ago

@porg We do have a prime cache feature that can cache a specified sitemap URL -- wp-admin/admin.php?page=w3tc_pgcache We do not have plans to make a sitemap converter (TXT to XML). WordPress redirects common sitemap URL requests to either wp-sitemap.xml or ?sitemap=index; see https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/sitemaps/class-wp-sitemaps-index.php#L78-L96 -- We prefer to let WordPress handle sitemaps. If you want to override it, there are sitemap plugins that may be useful. If you place your sitemap file in your filesystem, then WordPress should not redirect to its dynamically generated wp-sitemap.xml file.

porg commented 4 months ago

Thanks for your answer.

Among the points you addressed, you also wrote:

We do not have plans to make a sitemap converter (TXT to XML)

As I pointed out plaintext is a valid sitemap format per the sitemap.org spec. So why not support it? That reason I'd like to know.