dev

Motivation

Overview

Empirical Testing

Assumptions

Results

#!/bin/sh -eux

run_config() (
    [ $# -ge 2 ] || exit 1
    readonly __rc_name="$1" __rc_query_string_extra="$2"; shift 2
    [ ! -e "${__rc_name}" ] || exit 2

    __rc_request_id="$(printf '%s' "${__rc_name}" | openssl dgst -binary -sha1 | xxd -p | cut -c -16)"
    __rc_t00_outfile="${__rc_name}-t00.txt"
    __rc_t10_outfile="${__rc_name}-t10.txt"
    readonly __rc_request_id __rc_t00_outfile __rc_t10_outfile
    [ ! -e "${__rc_t00_outfile}" ] || exit 3
    [ ! -e "${__rc_t10_outfile}" ] || exit 4

    ( curl --silent --verbose --compressed --globoff -H 'fastly-debug: 1' -H 'fastly-force-shield: 1' "$@" "https://dev.wikia.com/api.php?format=json&requestid=${__rc_request_id}${__rc_query_string_extra}" >"${__rc_t00_outfile}" 2>&1 ) &&
    sleep 10 &&
    ( curl --silent --verbose --compressed --globoff -H 'fastly-debug: 1' -H 'fastly-force-shield: 1' "$@" "https://dev.wikia.com/api.php?format=json&requestid=${__rc_request_id}${__rc_query_string_extra}" >"${__rc_t10_outfile}" 2>&1 ) &&
    sleep 5
)

nonce=''              # set to something unique per run
anon_cookies=''       # set to that of an anon wikia session
logged_in_cookies=''  # set to that of a logged in wikia session
readonly nonce anon_cookies logged_in_cookies

run_config "${nonce}-00-public-without_maxages-anon"                                               '&action=query&meta=siteinfo'                          -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-01-public-without_maxages-logged_in"                                          '&action=query&meta=siteinfo'                          -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-02-public-with_maxages-anon"                           '&smaxage=600&maxage=600&action=query&meta=siteinfo'                          -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-03-public-with_maxages-logged_in"                      '&smaxage=600&maxage=600&action=query&meta=siteinfo'                          -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-04-private-without_maxages-anon"                                              '&action=query&meta=userinfo'                          -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-05-private-without_maxages-logged_in"                                         '&action=query&meta=userinfo'                          -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-06-private-with_maxages-anon"                          '&smaxage=600&maxage=600&action=query&meta=userinfo'                          -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-07-private-with_maxages-logged_in"                     '&smaxage=600&maxage=600&action=query&meta=userinfo'                          -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-08-anon_public_user_private-without_maxages-anon"                             '&action=query&meta=allmessages&amcustomised=modified' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-09-anon_public_user_private-without_maxages-logged_in"                        '&action=query&meta=allmessages&amcustomised=modified' -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-10-anon_public_user_private-with_maxages-anon"         '&smaxage=600&maxage=600&action=query&meta=allmessages&amcustomised=modified' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-11-anon_public_user_private-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=query&meta=allmessages&amcustomised=modified' -H "cookie: ${logged_in_cookies}"

Isolating the Weirdness

run_config "${nonce}-00-without_maxages-anon"                             '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp='                             -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-01-without_maxages-logged_in"                        '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp='                             -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-02-with_maxages-anon"         '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp='                             -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-03-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp='                             -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-04-without_maxages-anon"                             '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=API'                   -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-05-without_maxages-logged_in"                        '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=API'                   -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-06-with_maxages-anon"         '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=API'                   -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-07-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=API'                   -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-08-without_maxages-anon"                             '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=Special:RecentChanges' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-09-without_maxages-logged_in"                        '&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=Special:RecentChanges' -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-10-with_maxages-anon"         '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=Special:RecentChanges' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-11-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=parse&text={{FULLPAGENAME}}@{{CURRENTTIMESTAMP}}&prop=text&uselang=en&disablepp=&title=Special:RecentChanges' -H "cookie: ${logged_in_cookies}"
run_config "${nonce}-00-without_maxages-anon"                             '&action=query&meta=siteinfo'             -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-01-without_maxages-logged_in"                        '&action=query&meta=siteinfo'             -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-02-with_maxages-anon"         '&smaxage=600&maxage=600&action=query&meta=siteinfo'             -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-03-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=query&meta=siteinfo'             -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-04-without_maxages-anon"                             '&action=query&meta=siteinfo&title=dummy' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-05-without_maxages-logged_in"                        '&action=query&meta=siteinfo&title=dummy' -H "cookie: ${logged_in_cookies}" &&
run_config "${nonce}-06-with_maxages-anon"         '&smaxage=600&maxage=600&action=query&meta=siteinfo&title=dummy' -H "cookie: ${anon_cookies}"      &&
run_config "${nonce}-07-with_maxages-logged_in"    '&smaxage=600&maxage=600&action=query&meta=siteinfo&title=dummy' -H "cookie: ${logged_in_cookies}"
--- 02-with_maxages-anon-t00.cleaned_response_headers.txt
+++ 06-with_maxages-anon-t00.cleaned_response_headers.txt
@@ -1,27 +1,27 @@
 < HTTP/2 200 
 < server: Apache
 < x-content-type-options: nosniff
 < surrogate-key: wiki-7931 wiki-7931-mediawiki
 < content-security-policy-report-only: default-src https: 'self' data: blob:; script-src https: 'self' data: 'unsafe-inline' 'unsafe-eval' blob:; style-src https: 'self' 'unsafe-inline' blob:; report-uri https://services.wikia.com/csp-logger/csp/app
 < x-frame-options: DENY
 < content-disposition: inline; filename="api-result.json"
 < x-backend-response-time: […]
 < x-trace-id: […]
 < x-span-id: […]
-< cache-control: s-maxage=600, max-age=600, public
 < content-encoding: gzip
 < content-type: application/json; charset=utf-8
 < x-datacenter: SJC
 < x-cacheable: YES
 < accept-ranges: bytes
 < date: […]
 < age: 0
 < fastly-debug-path: (D cache-syd[…]-SYD […]) (D cache-wk-sjc[…]-WIKIA […])
 < fastly-debug-ttl: (M cache-syd[…]-SYD - - 0) (M cache-wk-sjc[…]-WIKIA - - 0)
 < fastly-debug-digest: […]
 < x-served-by: ap-s[…], cache-wk-sjc[…]-WIKIA, cache-syd[…]-SYD
 < x-cache: ORIGIN, MISS, MISS
 < x-cache-hits: ORIGIN, 0, 0
 < x-timer: […]
 < vary: Accept-Encoding,Cookie
+< cache-control: private, s-maxage=0, max-age=0, must-revalidate
 < content-length: […]

Official Response