/sitemap.xml reverse proxy cache issue – cache-control header should be configurable in admin UI

Created on 24 April 2025, 24 days ago

Issue summary:

When using a reverse proxy like Engintron (NGINX + cPanel integration), the /sitemap.xml virtual file is cached by the proxy and not refreshed properly, even though the actual sitemap XML files (e.g., sites/default/files/xmlsitemap/...) are updated correctly.

This happens because the XML Sitemap module does not send proper Cache-Control HTTP headers, so the proxy assumes it's safe to cache the response.

Proposed resolution:

Add a configuration option in the admin UI to allow site administrators to set the desired Cache-Control header for /sitemap.xml.

The default setting should be no caching, for example:

Cache-Control: no-cache, must-revalidate

This ensures search engines always receive the most up-to-date sitemap.

At the same time, this should remain configurable, because some administrators may want the sitemap to be cached for performance reasons.

Steps to reproduce:

Enable the XML Sitemap module and configure sitemap generation.

Create node which is included in the XML sitemap. Run cron.

Serve the site behind a reverse proxy such as Engintron.

Load /sitemap.xml — it gets cached and doesn't reflect updates.

The underlying file in sites/default/files/xmlsitemap/... is updated.

Visiting /sitemap.xml?foo=1 bypasses the cache and shows the updated version.

Additional information:

This behavior can lead to search engines indexing outdated sitemaps.

Easily testable with any reverse proxy setup (e.g., NGINX, Varnish, Cloudflare).

A simple header configuration in the module output could solve this.

Thanks in advance!

🐛 Bug report
Status

Active

Version

2.0

Component

xmlsitemap.module

Created by

🇭🇺Hungary kepesv

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024