summaryrefslogtreecommitdiff
path: root/include/rssfuncs.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-03-30 15:10:53 +0400
committerAndrew Dolgov <[email protected]>2013-03-30 15:12:20 +0400
commit7a01dc776ed6e124eac9db1a288d4aa5ab63b53d (patch)
treef43605d9941de5b513c573d5aacd6ff0e4a37ffb /include/rssfuncs.php
parent60b88b254c16a25c56e7016c1ef889b1d3e15c8b (diff)
support If-Modified-Since
Diffstat (limited to 'include/rssfuncs.php')
-rw-r--r--include/rssfuncs.php19
1 files changed, 15 insertions, 4 deletions
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',