X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRedirect.php;h=c4e4635ab56bcda22f94fdcaa1024c7ec2a2e54c;hp=1b2bda9a93484690454c908906dd0b304429b26c;hb=f661f3373eb500949b7e421b0df5a955d2904809;hpb=0770f85a0a293e6c7af6f1d3d3a1dbd2d13c1e09 diff --git a/includes/specials/SpecialRedirect.php b/includes/specials/SpecialRedirect.php index 1b2bda9a93..c4e4635ab5 100644 --- a/includes/specials/SpecialRedirect.php +++ b/includes/specials/SpecialRedirect.php @@ -119,7 +119,9 @@ class SpecialRedirect extends FormSpecialPage { // ... and we can if ( $mto && !$mto->isError() ) { // ... change the URL to point to a thumbnail. - $url = $mto->getUrl(); + // Note: This url is more temporary as can change + // if file is reuploaded and has different aspect ratio. + $url = [ $mto->getUrl(), $height === -1 ? 301 : 302 ]; } } @@ -224,7 +226,21 @@ class SpecialRedirect extends FormSpecialPage { break; } if ( $status && $status->isGood() ) { - $this->getOutput()->redirect( $status->getValue() ); + // These urls can sometimes be linked from prominent places, + // so varnish cache. + $value = $status->getValue(); + if ( is_array( $value ) ) { + list( $url, $code ) = $value; + } else { + $url = $value; + $code = 301; + } + if ( $code === 301 ) { + $this->getOutput()->setCdnMaxage( 60 * 60 ); + } else { + $this->getOutput()->setCdnMaxage( 10 ); + } + $this->getOutput()->redirect( $url, $code ); return true; }