Committer: vsukhanov
Add Expires and Cache-Control headers to /vgift/ and /userhead/ images.U trunk/cgi-bin/Apache/LiveJournal.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm =================================================================== --- trunk/cgi-bin/Apache/LiveJournal.pm 2010-09-22 09:29:25 UTC (rev 17432) +++ trunk/cgi-bin/Apache/LiveJournal.pm 2010-09-22 10:39:09 UTC (rev 17433) @@ -1428,8 +1428,26 @@ LJ::Request->content_type ($mime_type); LJ::Request->header_out("Content-length", $size); - LJ::Request->header_out("Cache-Control", "no-transform"); LJ::Request->header_out("Last-Modified", LJ::TimeUtil->time_to_http ($result->{change_time})); + ## Add Expires and Cache-Control headers + if ($uri =~ m|^/userhead/\d+|o){ + ## Userheads are never changed + my $max_age = 86400 * 365; # one year + my $expires_str = HTTP::Date::time2str(time + $max_age); + LJ::Request->header_out("Expires" => $expires_str); + LJ::Request->header_out("Cache-Control", "no-transform, public, max-age=$max_age"); + } elsif ($uri =~ m|^/vgift/\d+|){ + ## vgifts may be changed. + my $max_age = 86400 * 2 + 600; # 2 days and 10 minutes + my $expires_str = HTTP::Date::time2str(time + $max_age); + LJ::Request->header_out("Expires" => $expires_str); + LJ::Request->header_out("Cache-Control", "no-transform, public, max-age=$max_age"); + } else { + ## ... no Expires by defaul + ## Set Cache-Control only + LJ::Request->header_out("Cache-Control", "no-transform, public"); + } + LJ::Request->send_http_header(); return LJ::Request::OK; }