X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRedirect.php;h=c4e4635ab56bcda22f94fdcaa1024c7ec2a2e54c;hb=0dba85432c7110907c32453b0438560411b67de2;hp=1b2bda9a93484690454c908906dd0b304429b26c;hpb=4077b57759756ecd0d25427ec9598feb28a28ac1;p=lhc%2Fweb%2Fwiklou.git 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; }