Add MediaWiki-Timestamp header to ResourceLoader requests
authorOri Livneh <ori@wikimedia.org>
Fri, 3 Jul 2015 02:20:41 +0000 (19:20 -0700)
committerGilles Dubuc <gdubuc@wikimedia.org>
Wed, 15 Jul 2015 06:35:45 +0000 (08:35 +0200)
To help distinguish cache hits from cache misses, send a MediaWiki-Timestamp
header on ResourceLoader responses, indicating the current time as fractional
seconds since epoch, with microsecond precision.

Change-Id: I954a96ced1435a47d458de12411b257fe6b4ea34

includes/resourceloader/ResourceLoader.php

index 5d0ed3c..54cc6e5 100644 (file)
@@ -813,6 +813,11 @@ class ResourceLoader implements LoggerAwareInterface {
                        $exp = min( $maxage, $smaxage );
                        header( 'Expires: ' . wfTimestamp( TS_RFC2822, $exp + time() ) );
                }
+
+               // Send the current time expressed as fractional seconds since epoch,
+               // with microsecond precision. This helps distinguish hits from misses
+               // in edge caches.
+               header( 'MediaWiki-Timestamp: ' . microtime( true ) );
        }
 
        /**