]> git.wh0rd.org Git - tt-rss.git/commitdiff
generated feeds: support if-modified-since
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 1 Apr 2013 17:08:32 +0000 (21:08 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Mon, 1 Apr 2013 17:08:32 +0000 (21:08 +0400)
backend.php
classes/handler/public.php
public.php

index 41481a9635f59dbd21f78bc062f1db894ce3bfa2..9eb3989e4c2311b2837c838e761912d2ad32fe45 100644 (file)
@@ -43,8 +43,6 @@
        require_once "db.php";
        require_once "db-prefs.php";
 
-       no_cache_incantation();
-
        startup_gettext();
 
        $script_started = microtime(true);
index 37c704584798bc5bd5afb90857ff55db3e681b11..151447540a59f3de56edce0a853893741d870c70 100644 (file)
@@ -21,11 +21,32 @@ class Handler_Public extends Handler {
                else if ($feed == -1)
                        $date_sort_field = "last_marked DESC";
 
+               $qfh_ret = queryFeedHeadlines($this->link, $feed,
+                       1, $view_mode, $is_cat, $search, $search_mode,
+                       $date_sort_field, $offset, $owner_uid,
+                       false, 0, false, true);
+
+               $result = $qfh_ret[0];
+
+               if (db_num_rows($result) != 0) {
+                       $ts = strtotime(db_fetch_result($result, 0, "date_entered"));
+
+                       if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) &&
+                                       strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= $last_modified) {
+                     header('HTTP/1.0 304 Not Modified');
+                     return;
+                       }
+
+                       $last_modified = gmdate("D, d M Y H:i:s", $ts) . " GMT";
+                       header("Last-Modified: $last_modified", true);
+               }
+
                $qfh_ret = queryFeedHeadlines($this->link, $feed,
                        $limit, $view_mode, $is_cat, $search, $search_mode,
                        $date_sort_field, $offset, $owner_uid,
                        false, 0, false, true);
 
+
                $result = $qfh_ret[0];
                $feed_title = htmlspecialchars($qfh_ret[1]);
                $feed_site_url = $qfh_ret[2];
@@ -53,7 +74,8 @@ class Handler_Public extends Handler {
 
                        $tpl->setVariable('SELF_URL', htmlspecialchars(get_self_url_prefix()), true);
 
-                       while ($line = db_fetch_assoc($result)) {
+                       while ($line = db_fetch_assoc($result)) {
+
                                $tpl->setVariable('ARTICLE_ID', htmlspecialchars($line['link']), true);
                                $tpl->setVariable('ARTICLE_LINK', htmlspecialchars($line['link']), true);
                                $tpl->setVariable('ARTICLE_TITLE', htmlspecialchars($line['title']), true);
index dccd77f43b3353c9243d706e375a6ab5d96e8c15..8477f95fc8399f1f4959ed635b3c27e750b67e92 100644 (file)
@@ -24,8 +24,6 @@
        require_once "db.php";
        require_once "db-prefs.php";
 
-       no_cache_incantation();
-
        startup_gettext();
 
        $script_started = microtime(true);