Hi, I have a remote php service that builds an RSS file, and sets the headers that will avoid caching at the client:

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

I have an instance of drupal that is running Feeds. @ admin/build/feeds/edit/syndication/settings I've set my importer's basic settings with:

Minimum Refresh Period : As often as possible

However, I then do the following:

  1. Hit cron.php, and I see on remote web server that feed is sent (code 200).
  2. Hit cron.php again and I see that 304 Not Modified is returned (so no message-body is returned).

Maybe I'm not understanding things properly, but I'd expect that 304 should never be returned, as the remote service is setting Cache-Control: no-cache

If I hack feeds/libraries/http_request.inc, and remove the lines that set the 'If-Modified-Since' header, then subsequent calls to cron.php will result in my page always being returned (in other words, it gets rid of the 304 Not Modified "problem"):

    if (!empty($last_headers['Last-Modified'])) {
      if ($curl) {
        $headers[] = 'If-Modified-Since: '. $last_headers['Last-Modified'];
      }
      else {
        $headers['If-Modified-Since'] = $last_headers['Last-Modified'];
      }
    }

I'm trying to determine what exactly is wrong. Is the remote RSS service not setting a header that it should be? Is there a bug in http_request.inc? Or is this expected behaviour?

Cheers
Ryan

Comments

alex_b’s picture

Title: dealing with Cache-Control » http_request does not respect Cache-Control
Component: Miscellaneous » Code
Category: support » bug

That's a bug, the http_request library does not respect cache-control. A patch would be appreciated.

alex_b’s picture

Version: 6.x-1.0-beta7 » 6.x-1.x-dev

As reported here: #945378: Implement check for value "must-revalidate" in the "Cache-Control" header we need to make sure that 'no-cache' and 'must-revalidate' are both implemented properly.

twistor’s picture

Status: Active » Closed (works as designed)

Found this while working on Cache-Control. With regard to this issue, everything is working properly. Even if you set no-cache, must-revalidate, and Expires in the past, we should still use the "Last-Modified" and "ETag" headers in our request. Last-Modified and ETag are validators, used to supplement Cache-Control and Expires. It's up to the server to give the correct response to our request.