Adamw has submitted this change and it was merged.

Change subject: Fix bad caching in bannerController
......................................................................


Fix bad caching in bannerController

We removed $.ajaxSetup( cache: true ) in a previous revision; this
caused problems with cacheing. We now request the scripts via $.ajax
instead of <script>, and set cache:true locally.

Change-Id: Ie632136f2ef6e97989ac4b009ac9304895901fe8
---
M modules/ext.centralNotice.bannerController/bannerController.js
1 file changed, 23 insertions(+), 18 deletions(-)

Approvals:
  Adamw: Verified; Looks good to me, approved



diff --git a/modules/ext.centralNotice.bannerController/bannerController.js 
b/modules/ext.centralNotice.bannerController/bannerController.js
index c50aafa..c209153 100644
--- a/modules/ext.centralNotice.bannerController/bannerController.js
+++ b/modules/ext.centralNotice.bannerController/bannerController.js
@@ -48,32 +48,37 @@
                                country: mw.centralNotice.data.country,
                                device: mw.config.get( 'wgMobileDeviceName', 
'desktop' )
                        };
-                       scriptUrl = mw.config.get( 'wgCentralPagePath' ) + '?' 
+ $.param( bannerPageQuery );
-                       bannerScript = '<script src="' + mw.html.escape( 
scriptUrl ) + '"></script>';
-                       $( '#centralNotice' ).prepend( bannerScript );
+
+                       $.ajax({
+                               url: mw.config.get( 'wgCentralPagePath' ) + '?' 
+ $.param( bannerPageQuery ),
+                               dataType: 'script',
+                               cache: true
+                       });
                },
                loadRandomBanner: function () {
-                       var RAND_MAX = 30;
-
                        // TODO: Get rid of this when mobile support in CN is 
totally there
                        if ( mw.config.get( 'wgMobileDeviceName' ) ) {
                                return;
                        }
 
+                       var RAND_MAX = 30;
                        var bannerDispatchQuery = {
-                               userlang: mw.config.get( 'wgUserLanguage' ),
-                               sitename: mw.config.get( 'wgSiteName' ),
-                               project: mw.config.get( 'wgNoticeProject' ),
-                               anonymous: mw.config.get( 'wgUserName' ) === 
null,
-                               bucket: mw.centralNotice.data.bucket,
-                               country: mw.centralNotice.data.country,
-                               device: mw.config.get( 'wgMobileDeviceName', 
'desktop' ),
-                               slot: Math.floor( Math.random() * RAND_MAX ) + 1
-                       };
-                       var scriptUrl = mw.config.get( 
'wgCentralBannerDispatcher' )
-                               + '?' + $.param( bannerDispatchQuery );
-                       var bannerScript = '<script src="' + mw.html.escape( 
scriptUrl ) + '"></script>';
-                       $( '#centralNotice' ).prepend( bannerScript );
+                                       userlang: mw.config.get( 
'wgUserLanguage' ),
+                                       sitename: mw.config.get( 'wgSiteName' ),
+                                       project: mw.config.get( 
'wgNoticeProject' ),
+                                       anonymous: mw.config.get( 'wgUserName' 
) === null,
+                                       bucket: mw.centralNotice.data.bucket,
+                                       country: mw.centralNotice.data.country,
+                                       device: mw.config.get( 
'wgMobileDeviceName', 'desktop' ),
+                                       slot: Math.floor( Math.random() * 
RAND_MAX ) + 1
+                               };
+                       var scriptUrl = mw.config.get( 
'wgCentralBannerDispatcher' ) + '?' + $.param( bannerDispatchQuery );
+
+                       $.ajax({
+                               url: scriptUrl,
+                               dataType: 'script',
+                               cache: true
+                       });
                },
                // Record banner impression using old-style URL
                recordImpression: function( data ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/55626
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie632136f2ef6e97989ac4b009ac9304895901fe8
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/CentralNotice
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
Gerrit-Reviewer: Adamw <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to