diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-10 17:15:17 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-10 17:15:17 +0000 |
| commit | dd60ae2008f7cbeb452b46f28fde9002ec598f25 (patch) | |
| tree | d9855300f7b25c6dbed112d07f5b982541a2693c | |
| parent | e168e760e4948d8555096592ab2cb363b120c222 (diff) | |
When loading "blogs" script don't load all of WordPress. Only get the blog_id.
Added support for the if-modified-since http header so files can be cached.
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@154 7be80a69-a1ef-0310-a953-fb0f7c49ff36
| -rw-r--r-- | wp-inst/wp-content/blogs | 49 | ||||
| -rw-r--r-- | wp-inst/wp-settings.php | 3 |
2 files changed, 37 insertions, 15 deletions
diff --git a/wp-inst/wp-content/blogs b/wp-inst/wp-content/blogs index 5842897..20bad52 100644 --- a/wp-inst/wp-content/blogs +++ b/wp-inst/wp-content/blogs @@ -1,20 +1,39 @@ <?php +define( "BLOGDEFINITION", true ); require_once( "../wp-config.php" ); -if( is_file( ABSPATH . "wp-content/blogs.dir/" . $blog_id . $_SERVER[ 'REQUEST_URI' ] ) ) { - // get mime type - $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); - if( $ext == 'jpg' ) - $ext = 'jpeg'; - $mimetype = "image/$ext"; - header("Content-type: $mimetype" ); - readfile( ABSPATH . "wp-content/blogs.dir/" . $blog_id . $_SERVER[ 'REQUEST_URI' ] ); +$file = ABSPATH . "wp-content/blogs.dir/" . $blog_id . $_SERVER[ 'REQUEST_URI' ]; +if( is_file( $file ) ) { + $etag = md5( $file . filemtime( $file ) ); + $lastModified = date( "D, j M Y H:i:s ", filemtime( $file ) ) . "GMT"; + $headers = apache_request_headers(); + // get mime type + $ext = substr( $_SERVER[ 'REQUEST_URI' ], strrpos( $_SERVER[ 'REQUEST_URI' ], '.' ) + 1 ); + if( $ext == 'jpg' ) + $ext = 'jpeg'; + $mimetype = "image/$ext"; + + // from http://blog.rd2inc.com/archives/2005/03/24/making-dynamic-php-pages-cacheable/ + if( $lastModified == $headers['If-Modified-Since']) { + // They already have an up to date copy so tell them + header('HTTP/1.1 304 Not Modified'); + header('Cache-Control: private'); + header('Content-Type: $mimetype'); + header('ETag: "'.$eTag.'"'); + } else { + header("Content-type: $mimetype" ); + header( "Last-Modified: " . $lastModified ); + header( 'Accept-Ranges: bytes' ); + header( "Content-Length: " . filesize( $file ) ); + header( 'ETag: "' . $etag . '"' ); + readfile( $file ); + } } else { - // 404 - header("HTTP/1.1 404 Not Found"); - print "<html><head><title>Error 404! File Not Found!</title></head>"; - print "<body>"; - print "<h1>File Not Found!</h1>"; - print "No! No! Run Away! This file has escaped and is running wild!"; - print "</body></html>"; + // 404 + header("HTTP/1.1 404 Not Found"); + print "<html><head><title>Error 404! File Not Found!</title></head>"; + print "<body>"; + print "<h1>File Not Found!</h1>"; + print "No! No! Run Away! This file has escaped and is running wild!"; + print "</body></html>"; } ?> diff --git a/wp-inst/wp-settings.php b/wp-inst/wp-settings.php index af6cee6..877aea1 100644 --- a/wp-inst/wp-settings.php +++ b/wp-inst/wp-settings.php @@ -171,6 +171,9 @@ $tablepostmeta = $wpdb->postmeta; $wp_filters = array(); +if( defined( "BLOGDEFINITION" ) && constant( "BLOGDEFINITION" ) == true ) + return; + require (ABSPATH . WPINC . '/functions.php'); require (ABSPATH . WPINC . '/default-filters.php'); require_once (ABSPATH . WPINC . '/wp-l10n.php'); |
