Index: trunk/phase3/includes/api/ApiMain.php |
— | — | @@ -262,14 +262,20 @@ |
263 | 263 | |
264 | 264 | $params = $this->extractRequestParams(); |
265 | 265 | if($this->mSquidMaxage == -1) |
266 | | - # Nobody called setCacheMaxAge(), use the smaxage parameter |
267 | | - $this->mSquidMaxage = $params['smaxage']; |
268 | | - |
| 266 | + { |
| 267 | + # Nobody called setCacheMaxAge(), use the (s)maxage parameters |
| 268 | + $smaxage = $params['smaxage']; |
| 269 | + $maxage = $params['maxage']; |
| 270 | + } |
| 271 | + else |
| 272 | + $smaxage = $maxage = $this->mSquidMaxage; |
| 273 | + |
269 | 274 | // Set the cache expiration at the last moment, as any errors may change the expiration. |
270 | 275 | // if $this->mSquidMaxage == 0, the expiry time is set to the first second of unix epoch |
271 | | - $expires = $this->mSquidMaxage == 0 ? 1 : time() + $this->mSquidMaxage; |
| 276 | + $exp = min($smaxage, $maxage); |
| 277 | + $expires = $exp == 0 ? 1 : time() + $this->mSquidMaxage; |
272 | 278 | header('Expires: ' . wfTimestamp(TS_RFC2822, $expires)); |
273 | | - header('Cache-Control: s-maxage=' . $this->mSquidMaxage . ', must-revalidate, max-age=0'); |
| 279 | + header('Cache-Control: s-maxage=' . $smaxage . ', must-revalidate, max-age=' . $maxage); |
274 | 280 | |
275 | 281 | if($this->mPrinter->getIsHtml()) |
276 | 282 | echo wfReportTime(); |
— | — | @@ -420,6 +426,10 @@ |
421 | 427 | ApiBase :: PARAM_TYPE => 'integer', |
422 | 428 | ApiBase :: PARAM_DFLT => 0 |
423 | 429 | ), |
| 430 | + 'maxage' => array ( |
| 431 | + ApiBase :: PARAM_TYPE => 'integer', |
| 432 | + ApiBase :: PARAM_DFLT => 0 |
| 433 | + ), |
424 | 434 | ); |
425 | 435 | } |
426 | 436 | |
— | — | @@ -432,7 +442,8 @@ |
433 | 443 | 'action' => 'What action you would like to perform', |
434 | 444 | 'version' => 'When showing help, include version for each module', |
435 | 445 | 'maxlag' => 'Maximum lag', |
436 | | - 'smaxage' => 'Cache the result for this many seconds. Errors are never cached', |
| 446 | + 'smaxage' => 'Set the s-maxage header to this many seconds. Errors are never cached', |
| 447 | + 'maxage' => 'Set the max-age header to this many seconds. Errors are never cached', |
437 | 448 | ); |
438 | 449 | } |
439 | 450 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -450,7 +450,7 @@ |
451 | 451 | * (bug 14526) Unescaped SQL in list=backlinks |
452 | 452 | * Added 'hidden' flag to list=allcategories and prop=categoryinfo output |
453 | 453 | * Added nocreate parameter to action=edit |
454 | | -* (bug 14402) Added smaxage parameter to api.php |
| 454 | +* (bug 14402) Added maxage and smaxage parameters to api.php |
455 | 455 | |
456 | 456 | === Languages updated in 1.13 === |
457 | 457 | |