Index: trunk/extensions/FeaturedFeeds/ApiFeaturedFeeds.php |
— | — | @@ -40,10 +40,13 @@ |
41 | 41 | |
42 | 42 | ApiFormatFeedWrapper::setResult( $this->getResult(), $feedClass, $ourFeed['entries'] ); |
43 | 43 | |
| 44 | + // Cache stuff in squids |
| 45 | + $this->getMain()->setCacheMode( 'public' ); |
| 46 | + $this->getMain()->setCacheMaxAge( FeaturedFeeds::getMaxAge() ); |
| 47 | + |
44 | 48 | wfProfileOut( __METHOD__ ); |
45 | 49 | } |
46 | 50 | |
47 | | - |
48 | 51 | public function getAllowedParams() { |
49 | 52 | global $wgFeedClasses; |
50 | 53 | $feedFormatNames = array_keys( $wgFeedClasses ); |
Index: trunk/extensions/FeaturedFeeds/FeaturedFeeds.body.php |
— | — | @@ -24,9 +24,7 @@ |
25 | 25 | |
26 | 26 | if ( !$feeds ) { |
27 | 27 | $feeds = self::getFeedsInternal( $langCode ); |
28 | | - // add 10 seconds to cater for time deviation between servers |
29 | | - $expiry = self::todaysStart() + 24 * 3600 - wfTimestamp() + 10; |
30 | | - $wgMemc->set( $key, $feeds, min( $expiry, 3600 ) ); |
| 28 | + $wgMemc->set( $key, $feeds, self::getMaxAge() ); |
31 | 29 | } |
32 | 30 | $cache[$langCode] = $feeds; |
33 | 31 | return $feeds; |
— | — | @@ -168,4 +166,15 @@ |
169 | 167 | } |
170 | 168 | return wfScript( 'api' ) . '?' . wfArrayToCGI( $options ); |
171 | 169 | } |
| 170 | + |
| 171 | + /** |
| 172 | + * Returns the number of seconds a feed should stay in cache |
| 173 | + * |
| 174 | + * @return int: Time in seconds |
| 175 | + */ |
| 176 | + public static function getMaxAge() { |
| 177 | + // add 10 seconds to cater for time deviation between servers |
| 178 | + $expiry = self::todaysStart() + 24 * 3600 - wfTimestamp() + 10; |
| 179 | + return min( $expiry, 3600 ); |
| 180 | + } |
172 | 181 | } |
\ No newline at end of file |