Skip to content

Instantly share code, notes, and snippets.

@btompkins
Last active December 11, 2015 05:08
Show Gist options
  • Save btompkins/4550305 to your computer and use it in GitHub Desktop.
Save btompkins/4550305 to your computer and use it in GitHub Desktop.
When using a custom loop.php and a reverse front end cache like NGINX, you'll need to emit the Last-Modified header, this index.php file will do that, otherwise your front-end cache won't expire when a blog is updated.
<?php
$last_updated = $wpdb->get_var( "SELECT last_updated FROM " . $wpdb->blogs. " WHERE public = '1' order by
`last_updated` desc limit 1");
if(isset($last_updated)){
$post_mod_date=date("D, d M Y H:i:s",strtotime($last_updated));
header('Last-Modified: '.$post_mod_date.' GMT');
}
get_header();?>
<div id="content">
<div id="main" class="grid_8">
<?php if(function_exists('wp_greet_box')){wp_greet_box();} ?>
<?php get_template_part( 'loop', 'index' ); ?>
</div><!-- #main -->
<div id="sidebar" class="grid_4">
<?php get_sidebar(); ?>
</div><!--sidebar-->
</div><!-- #content -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment