Hi,

We are currently experiencing a problem with varnish caching the XML sitemap for the default lifetime for a resource that does not specific a minimum cache lifetime.

Can a 'Cache-Control' header of 'max-age' be added ?

Attached is a simple patch that provides this.

Issue fork xmlsitemap-1959468

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Anonymous’s picture

Category: bug » feature

Not a bug certainly.

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 6 year old patch to xmlsitemap.pages.inc does not apply to the latest xmlsitemap 7.x-2.x-dev and if still applicable needs a reroll.

Checking patch xmlsitemap.pages.inc...
error: while searching for:
    exit;
  }

  $headers += array(
    'Content-type' => 'text/xml; charset=utf-8',
    //'Content-length' => filesize($file),
    'Last-modified' => $last_modified,
    'Etag' => $etag,
    'Expires' => gmdate(DATE_RFC1123, $mtime + variable_get('xmlsitemap_minimum_lifetime', 0)),
    'Cache-Control' => 'must-revalidate',
    'X-Robots-Tag' => 'noindex, follow',
  );


error: patch failed: xmlsitemap.pages.inc:79
error: xmlsitemap.pages.inc: patch does not apply
klidifia’s picture

Status: Needs work » Needs review
StatusFileSize
new743 bytes

Reroll: Commented line in the $headers array was removed.

rpayanm’s picture

Issue tags: -Needs reroll
dave reid’s picture

Do we also need to fix this in D8?

dave reid’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
Issue tags: +Needs backport to D7

Looks like it.

klidifia’s picture

StatusFileSize
new743 bytes

A reroll for 7.x

malcomio’s picture

On #3521048: /sitemap.xml reverse proxy cache issue – cache-control header should be configurable in admin UI, @kepesv suggested adding a UI to set the cache-control value, and @bmunslow provided a patch, although that explicitly sets a no-cache header.

malcomio’s picture

Status: Needs review » Needs work
malcomio’s picture

Status: Needs work » Needs review
loze’s picture

should this be against 2.x ?

malcomio’s picture

Version: 8.x-1.x-dev » 2.x-dev
Status: Needs review » Needs work

@loze yes you're probably right - because 8.x-1.6 is a more recent release than 2.0.0, I assumed that was the active version.

Have opened MR 75 against 2.x, but haven't tested that branch fully yet

malcomio’s picture

Having applied this patch, we have observed odd behaviour where incomplete sitemap pages are cached in Cloudflare.