From 7a01dc776ed6e124eac9db1a288d4aa5ab63b53d Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 30 Mar 2013 15:10:53 +0400 Subject: support If-Modified-Since --- include/rssfuncs.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'include/rssfuncs.php') diff --git a/include/rssfuncs.php b/include/rssfuncs.php index e82e94b09..7c668f69f 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -239,6 +239,7 @@ $rss = false; $rss_hash = false; + $cache_timestamp = file_exists($cache_filename) ? filemtime($cache_filename) : 0; if (file_exists($cache_filename) && is_readable($cache_filename) && @@ -261,11 +262,11 @@ if (!$feed_data) { if ($debug_enabled) { - _debug("update_rss_feed: fetching [$fetch_url]..."); + _debug("update_rss_feed: fetching [$fetch_url] (ts: $cache_timestamp)"); } $feed_data = fetch_file_contents($fetch_url, false, - $auth_login, $auth_pass, false, $no_cache ? 15 : 45); + $auth_login, $auth_pass, false, $no_cache ? 15 : 45, $cache_timestamp); if ($debug_enabled) { _debug("update_rss_feed: fetch done."); @@ -275,12 +276,22 @@ if (!$feed_data) { global $fetch_last_error; + global $fetch_last_error_code; if ($debug_enabled) { - _debug("update_rss_feed: unable to fetch: $fetch_last_error"); + _debug("update_rss_feed: unable to fetch: $fetch_last_error [$fetch_last_error_code]"); } - $error_escaped = db_escape_string($link, $fetch_last_error); + $error_escaped = ''; + + // If-Modified-Since + if ($fetch_last_error_code != 304) { + $error_escaped = db_escape_string($link, $fetch_last_error); + } else { + if ($debug_enabled) { + _debug("update_rss_feed: source claims data not modified, nothing to do."); + } + } db_query($link, "UPDATE ttrss_feeds SET last_error = '$error_escaped', -- cgit v1.2.3