Support If-modified-since for RawPage, fixes bug #10023.
authorGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 10 Jan 2012 18:16:38 +0000 (18:16 +0000)
committerGabriel Wicke <gwicke@users.mediawiki.org>
Tue, 10 Jan 2012 18:16:38 +0000 (18:16 +0000)
The check to WikiPage::getTouched will load the latest revision data, which is
not ideal for performance. In a quick test using ab -c 100 -n 1000 and without
MemCached enabled, the request rate for plain GET requests drops slightly from
108 to 104 req/second. As described in my comment
https://bugzilla.wikimedia.org/show_bug.cgi?id=10023#c9, this could certainly be
improved on. Overall, a few unmodified responses should still make the
server-side performance impact of this patch positive, while improving
client-side performance considerably for unmodified content.

includes/actions/RawAction.php

index 019d538..2dcc387 100644 (file)
@@ -42,6 +42,10 @@ class RawAction extends FormlessAction {
                        return;
                }
 
+               if ( $this->getOutput()->checkLastModified( $this->page->getTouched() ) ) {
+                       return; // Client cache fresh and headers sent, nothing more to do.
+               }
+
                # special case for 'generated' raw things: user css/js
                # This is deprecated and will only return empty content
                $gen = $request->getVal( 'gen' );