- Timestamp:
- 08/16/13 00:09:23 (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BookmarkApp.pm
r53 r57 7 7 8 8 use Encode; 9 use HTTP::Date qw{time2isoz time2iso };9 use HTTP::Date qw{time2isoz time2iso time2str str2time}; 10 10 use JSON; 11 11 use Bookmarks; … … 135 135 136 136 # list all the bookmarks 137 my $mtime = $self->_bookmarks->get_last_modified_time; 138 137 139 my $format = $q->param('format') || 'html'; 138 140 … … 239 241 -type => 'text/html', 240 242 -charset => 'UTF-8', 243 -Last_Modified => time2str($mtime), 241 244 ); 242 245 … … 335 338 my $bookmark = $self->_bookmarks->get_bookmark({ id => $id }); 336 339 if ($bookmark) { 340 # check If-Modified-Since header to return cache response 341 if ($self->query->env->{HTTP_IF_MODIFIED_SINCE}) { 342 my $cache_time = str2time($self->query->env->{HTTP_IF_MODIFIED_SINCE}); 343 if ($bookmark->mtime <= $cache_time) { 344 $self->header_type('redirect'); 345 $self->header_props( 346 -status => 304, 347 ); 348 return; 349 } 350 } 351 337 352 if ($format eq 'json') { 338 353 $self->header_props( … … 349 364 -type => 'text/html', 350 365 -charset => 'UTF-8', 366 -Last_Modified => time2str($bookmark->mtime), 351 367 ); 352 368 return $self->tt_process( -
trunk/Bookmarks.pm
r52 r57 169 169 $sth->execute(@bind); 170 170 return @{ $sth->fetchall_arrayref({}) }; 171 } 172 173 sub get_last_modified_time { 174 my $self = shift; 175 my $sth = $self->dbh->prepare('select mtime from bookmarks order by mtime desc limit 1'); 176 $sth->execute; 177 my ($mtime) = $sth->fetchrow_array; 178 return $mtime; 171 179 } 172 180
Note: See TracChangeset
for help on using the changeset viewer.