Changeset 71
- Timestamp:
- 05/27/05 16:37:47 (3 years ago)
- Files:
-
- FlickrPublicPhotos/trunk/FlickrPublicPhotos.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
FlickrPublicPhotos/trunk/FlickrPublicPhotos.pl
r70 r71 68 68 my ($ctx, $args) = @_; 69 69 my $user = $args->{user} or $ctx->error("'user' must be specified"); 70 71 my @photos = eval { load_photos($user, $ args->{refresh} || 3600); };70 my $refresh = $args->{refresh} || 3600; # default: 1h 71 my @photos = eval { load_photos($user, $refresh); }; 72 72 # if MT::PluginData is unavailable 73 73 @photos = eval { load_photos_fapi($user); } if $@; … … 109 109 my $cache = $args->{cache} or return $url; 110 110 $cache .= '/' unless $cache =~ m!/$!; 111 my $refresh = $args->{cache_refresh} || 86400; # default: 24h 111 112 112 113 my ($fname) = $url =~ m!^https?://.+/(.*)$!; … … 126 127 $path .= $fname; 127 128 129 my $mtime = 0; 130 if ($fmgr->exists($path)) { 131 $mtime = (stat($path))[9]; 132 return $site_url if ($refresh && (time - $mtime < $refresh)); 133 } 134 128 135 require LWP::UserAgent; 129 136 require HTTP::Request; … … 132 139 my $req = HTTP::Request->new(GET => $url); 133 140 my $ua = LWP::UserAgent->new; 134 if ($fmgr->exists($path) && (my $mtime = (stat($path))[9])) { 135 $req->header('If-Modified-Since', HTTP::Date::time2str($mtime)); 136 } 141 $req->header('If-Modified-Since', HTTP::Date::time2str($mtime)) if $mtime; 137 142 my $rsp = $ua->request($req); 138 143 if ($rsp->is_success && $rsp->content) {
