Author: metatron
Description:
When loading a gagdget or custom script from eg. meta/mediawiki/enwiki with
-mw.loader.load('//meta.wikimedia.org/w/index.php?title=...&action=raw&ctype=...')
the responded cache-control directive is
- private, s-maxage=0, max-age=0, must-revalidate
which prevents these scripts from being cached properly and causes a lag (40-500ms) on each call.
(IMHO JS pages should have a reasonable default > 0)
Example with requested cache:
Remote Address:xx.xx.xx.xx:443 Request URL:https://meta.wikimedia.org/w/index.php?title=User:Hedonil/Test/XTools.js&action=raw&ctype=text/javascript&maxage=86400&smaxage=86400 Request Method:GET Status Code:304 Not Modified Request Headersview source Accept:*/* Accept-Encoding:gzip,deflate,sdch Accept-Language:en,no;q=0.8,nb;q=0.6,vi;q=0.4,nl;q=0.2,zh;q=0.2,ru;q=0.2,en-US;q=0.2,zh-CN;q=0.2,zh-TW;q=0.2 Connection:keep-alive metawikiUserID=..centralauth_User.. Host:meta.wikimedia.org If-Modified-Since:Wed, 13 Aug 2014 04:18:39 GMT Referer:https://en.wikipedia.org/wiki/Charles_Schild User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 Query String Parametersview sourceview URL encoded title:User:Hedonil/Test/XTools.js action:raw ctype:text/javascript maxage:86400 smaxage:86400 Response Headersview source Accept-Ranges:bytes Age:0 Cache-Control:private, s-maxage=0, max-age=0, must-revalidate Connection:keep-alive Content-Encoding:gzip Content-Type:text/javascript; charset=UTF-8 Date:Wed, 13 Aug 2014 07:55:42 GMT Last-modified:Wed, 13 Aug 2014 04:18:39 GMT Server:nginx/1.1.19 Vary:Accept-Encoding Via:1.1 varnish, 1.1 varnish, 1.1 varnish X-Cache:cp1065 miss (0), amssq50 miss (0), amssq31 frontend miss (0) X-Content-Type-Options:nosniff X-Varnish:948365503, 2378009697, 4022640906 ConsoleSearchEmulationRendering
Example without requested directive:
Remote Address:xx.xx.xx.xx:443 Request URL:https://en.wikipedia.org/w/index.php?title=MediaWiki%3AGadget-HotCat.js%2Flocal_defaults&action=raw&ctype=text/javascript Request Method:GET Status Code:304 Not Modified Request Headersview source Accept:*/* Accept-Encoding:gzip,deflate,sdch Accept-Language:en,no;q=0.8,nb;q=0.6,vi;q=0.4,nl;q=0.2,zh;q=0.2,ru;q=0.2,en-US;q=0.2,zh-CN;q=0.2,zh-TW;q=0.2 Connection:keep-alive Cookie:enwikiSession=..centralauth_User=... Host:en.wikipedia.org If-Modified-Since:Mon, 23 Jun 2014 19:15:43 GMT Referer:https://en.wikipedia.org/wiki/Charles_Schild User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 Query String Parametersview sourceview URL encoded title:MediaWiki:Gadget-HotCat.js/local_defaults action:raw ctype:text/javascript Response Headersview source Accept-Ranges:bytes Age:0 Cache-Control:private, s-maxage=0, max-age=0, must-revalidate Connection:keep-alive Content-Encoding:gzip Content-Type:text/javascript; charset=UTF-8 Date:Wed, 13 Aug 2014 07:55:42 GMT Last-modified:Mon, 23 Jun 2014 19:15:43 GMT Server:nginx/1.1.19 Vary:Accept-Encoding Via:1.1 varnish, 1.1 varnish, 1.1 varnish X-Cache:cp1053 miss (0), amssq55 miss (0), amssq54 frontend miss (0) X-Content-Type-Options:nosniff X-Varnish:2605122819, 917135542, 2533692991