Send cache purges for action=raw after editing user css/js

These types of requests can be cached for a short time (~5 min) in
Squid/Varnish.

Change importScript to be consistent with importStylesheet in the query
parameter order (title, action, ctype).

We only send purges for the exact urls as used by importScript and
importStylesheet.

Note: ResourceLoader things have their cache handled separately and
aren't affected by this change.

Users like instant updating of scripts after having changed them.

Bug: 56874
Change-Id: Idaa8552cf371dbafeb8b730f35b3b5c4fc339fb0
This commit is contained in:
Brian Wolff 2013-11-12 23:00:07 -04:00 committed by Krinkle
parent 3ebfa0acfc
commit 6e2be46e82
3 changed files with 14 additions and 3 deletions

View file

@ -3538,6 +3538,13 @@ class Title {
}
}
// If we are looking at a css/js user subpage, purge the action=raw.
if ( $this->isJsSubpage() ) {
$urls[] = $this->getInternalUrl( 'action=raw&ctype=text/javascript' );
} elseif ( $this->isCssSubpage() ) {
$urls[] = $this->getInternalUrl( 'action=raw&ctype=text/css' );
}
wfRunHooks( 'TitleSquidURLs', array( $this, &$urls ) );
return $urls;
}

View file

@ -77,7 +77,8 @@ class RawAction extends FormlessAction {
$contentType = $this->getContentType();
# Force caching for CSS and JS raw content, default: 5 minutes
# Force caching for CSS and JS raw content, default: 5 minutes.
# Note: If using a canonical url for userpage css/js, we send an HTCP purge.
if ( $smaxage === null ) {
if ( $contentType == 'text/css' || $contentType == 'text/javascript' ) {
$smaxage = intval( $wgForcedRawSMaxage );

View file

@ -226,8 +226,11 @@ win.importScriptURI = function ( url ) {
return s;
};
win.importStylesheet = function( page ) {
return win.importStylesheetURI( mw.config.get( 'wgScript' ) + '?action=raw&ctype=text/css&title=' + mw.util.wikiUrlencode( page ) );
win.importStylesheet = function ( page ) {
var uri = mw.config.get( 'wgScript' ) + '?title=' +
mw.util.wikiUrlencode( page ) +
'&action=raw&ctype=text/css';
return win.importStylesheetURI( uri );
};
win.importStylesheetURI = function( url, media ) {