Index: /trunk/BookmarkController.pm
===================================================================
--- /trunk/BookmarkController.pm	(revision 61)
+++ /trunk/BookmarkController.pm	(revision 62)
@@ -265,8 +265,4 @@
     $feed->title($title);
 
-    my $feed_uri = URI->new_abs('feed', $self->base_uri);
-    $feed_uri->query_form(tag => \@tags);
-    $feed->id($feed_uri->canonical);
-
     for my $link ($self->_get_list_links('application/atom+xml', { q => $query, tag => \@tags })) {
         my $atom_link = XML::Atom::Link->new;
@@ -308,4 +304,21 @@
 }
 
+#TODO: better method name
+# returns 1 if there is an If-Modified-Since header and it is newer than the given $mtime
+# returns 0 if there is an If-Modified-Since header but the $mtime is newer
+# returns undef if there is no If-Modified-Since header
+sub _check_modified {
+    my $self = shift;
+    my $mtime = shift;
+
+    # check If-Modified-Since header to return cache response
+    if ($self->request->env->{HTTP_IF_MODIFIED_SINCE}) {
+        my $cache_time = str2time($self->request->env->{HTTP_IF_MODIFIED_SINCE});
+        return $mtime <= $cache_time ? 1 : 0;
+    } else {
+        return;
+    }
+}
+
 sub view {
     my ($self, $id) = @_;
@@ -315,11 +328,6 @@
     my $bookmark = $self->get_bookmark({ id => $id });
     if ($bookmark) {
-        # check If-Modified-Since header to return cache response
-        if ($self->request->env->{HTTP_IF_MODIFIED_SINCE}) {
-            my $cache_time = str2time($self->request->env->{HTTP_IF_MODIFIED_SINCE});
-            if ($bookmark->mtime <= $cache_time) {
-                return [304, [], []];
-            }
-        }
+        return [304, [], []] if $self->_check_modified($bookmark->mtime);
+
         my $last_modified = time2str($bookmark->mtime);
         
@@ -348,6 +356,8 @@
     my ($self, $id, $field) = @_;
 
-    my $bookmark = $self->bookmarks->get_bookmark({ id => $id });
+    my $bookmark = $self->get_bookmark({ id => $id });
     if ($bookmark) {
+        return [304, [], []] if $self->_check_modified($bookmark->mtime);
+
         # respond with just the requested field as plain text
         my $value = eval { $bookmark->$field };
@@ -359,5 +369,6 @@
             }
         }
-        return [200, ['Content-Type' => 'text/plain; charset=UTF-8'], [ref $value eq 'ARRAY' ? join(' ', @{ $value }) : $value]];
+        my $last_modified = time2str($bookmark->mtime);
+        return [200, ['Content-Type' => 'text/plain; charset=UTF-8', 'Last-Modified' => $last_modified], [ref $value eq 'ARRAY' ? join(' ', @{ $value }) : $value]];
     } else {
         return [404, ['Content-Type' => 'text/plain; charset=UTF-8'], ["Boomark $id not found"]];
