Committer: sbelyaev
LJSUP-13301: Main page optimizationU trunk/cgi-bin/LJ/Nav.pm
Modified: trunk/cgi-bin/LJ/Nav.pm =================================================================== --- trunk/cgi-bin/LJ/Nav.pm 2012-08-17 15:02:55 UTC (rev 12490) +++ trunk/cgi-bin/LJ/Nav.pm 2012-08-20 07:03:58 UTC (rev 12491) @@ -22,14 +22,19 @@ $scheme ||= "default"; $opts ||= {}; - my $journal = $remote ? $remote->userid : 'non'; - my $memcache_key = "navbar:$scheme:$journal:" . $LJ::CURRENT_VERSION; + my $memcache_key; + if ($remote) { + my $journalid = $remote->userid; + my $bl = LJ::Lang::get_lang($remote->prop('browselang')); + + $memcache_key = "navbar:$scheme:$journalid:$bl" . $LJ::CURRENT_VERSION; - my $cached = LJ::MemCache::get($memcache_key); - if ($cached) { - my %POST = LJ::Request->post_params; - unless (exists $POST{'ljpost:on'} || exists $POST{'ljpost:off'}) { - return @{LJ::JSON->from_json($cached)}; + my $cached = LJ::MemCache::get($memcache_key); + if ($cached) { + my %POST = LJ::Request->post_params; + unless (exists $POST{'ljpost:on'} || exists $POST{'ljpost:off'}) { + return @{LJ::JSON->from_json($cached)}; + } } } @@ -62,8 +67,11 @@ push @nav_filtered, $section; } - my $cache_data = LJ::JSON->to_json(\@nav_filtered); - LJ::MemCache::set($memcache_key, $cache_data, NAV_CACHE_TIME); + if ($memcache_key) { + my $cache_data = LJ::JSON->to_json(\@nav_filtered); + LJ::MemCache::set($memcache_key, $cache_data, NAV_CACHE_TIME); + } + return @nav_filtered; }