• Resolved 1stwebdesigns

    (@1stwebdesigns)


    We’ve written our own XML sitemap generator, which returns a Content-Type header like so:

    header( ‘Content-Type: text/xml’ );

    When viewing the sitemap page for the first time, the browser renders it as XML. However, once it is cached, subsequent calls return a Content-Type of text/html and the browser doesn’t render the XML (or the linked XSL stylesheet file).

    I notice the same behaviour too with the Yoast SEO plugin and their sitemap.

    What is the correct way of ensuring the text/xml header is honoured after the page is cached?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @1stwebdesigns

    Thank you for your inquiry and I am happy to assist you with this.
    The sitemap is our template – enable XML caching in Performance>Browser Cache and it will start to provide text/XML header instead.
    Thank you!

    Thread Starter 1stwebdesigns

    (@1stwebdesigns)

    Thanks for your reply – however we are not using the Browser Cache settings and these are turned off, the only thing we use is Page Cache.

    • This reply was modified 4 years, 10 months ago by 1stwebdesigns.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @1stwebdesigns

    Just to confirm, once Page Cache is disabled you are no longer experiencing the issue?
    Is the option Cache feeds: site, categories, tags, comments” on the “Page Cache” settings tab enabled? Some sitemap implementations are considered by WordPress to be “feeds.”
    Thanks!

    Thread Starter 1stwebdesigns

    (@1stwebdesigns)

    Yes, once Page Cache is disabled, the issue goes away.

    According to the comment at the bottom of the page, the XML feed is being cached.

    On the initial get, the header returned is text/xml. Then on a subsequent get (after it’s been cached), the header returned is text/html.

    I tried the option “Cache feeds: site, categories, tags, comments” but it didn’t make any difference.

    Just to add to the above, when I look in the cache directory, within page_enhanced there is a directory called sitemap.xml and within that is a file called _index_ssl.html – so I’m not sure if that’s expected, but there doesn’t seem to be any obvious way for the original text/xml header to be returned from the cached document.

    • This reply was modified 4 years, 10 months ago by 1stwebdesigns.
    • This reply was modified 4 years, 10 months ago by 1stwebdesigns.
    • This reply was modified 4 years, 10 months ago by 1stwebdesigns.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘XML sitemap header wrong after caching’ is closed to new replies.