summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2013-04-01 21:08:32 +0400
committerAndrew Dolgov <[email protected]>2013-04-01 21:08:32 +0400
commit2e35a7070b17a7bbc01730071391382f9cbe09ea (patch)
treef8607926a024ff3b0e49c36812e0a5735961f133
parentf0e015c428e9bdbcab5e0b3313baca694146477a (diff)
generated feeds: support if-modified-since
-rw-r--r--backend.php2
-rw-r--r--classes/handler/public.php24
-rw-r--r--public.php2
3 files changed, 23 insertions, 5 deletions
diff --git a/backend.php b/backend.php
index 41481a963..9eb3989e4 100644
--- a/backend.php
+++ b/backend.php
@@ -43,8 +43,6 @@
require_once "db.php";
require_once "db-prefs.php";
- no_cache_incantation();
-
startup_gettext();
$script_started = microtime(true);
diff --git a/classes/handler/public.php b/classes/handler/public.php
index 37c704584..151447540 100644
--- a/classes/handler/public.php
+++ b/classes/handler/public.php
@@ -22,10 +22,31 @@ class Handler_Public extends Handler {
$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);
diff --git a/public.php b/public.php
index dccd77f43..8477f95fc 100644
--- a/public.php
+++ b/public.php
@@ -24,8 +24,6 @@
require_once "db.php";
require_once "db-prefs.php";
- no_cache_incantation();
-
startup_gettext();
$script_started = microtime(true);