-1

I am trying to use REDIS caching outside of wordpress, and in my index.php, I'm basically wrapping the two PHP lines to start output buffering and end output buffering... however, it's not working as expected.

ob_start();

define('WP_USE_THEMES', true);
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

$buffer = ob_get_contents();
ob_end_clean();

$buffer only contains the HTML source BEFORE W3 total cache does its work... we want to be able to capture the source AFTER W3 total cache does its work. Any ideas?

Rob W
  • 9,134
  • 1
  • 30
  • 50
  • I would just check out [Varnish](https://www.varnish-cache.org/) rather than modifying core files, but in general trying to mix caching solutions is going to get tricky. – doublesharp Jul 26 '14 at 06:58
  • I'm on the Azure platform though, I don't believe I can without switching to a VM, which the client doesn't want... surely there has to be a way! – Rob W Jul 26 '14 at 17:46
  • W3TC provides caching, you don't need redis on top of it. – doublesharp Jul 26 '14 at 20:52
  • I'd rather serve a cached page without WP doing any sort of processing. Look up redis, you might just fall in love ;) – Rob W Jul 27 '14 at 01:22

1 Answers1

1

Come to find out, w3 total cache doesn't close all ob's.

Resolution:

  ob_start();
  $level = ob_get_level();
  require('./wp-blog-header.php');
  while(ob_get_level() > $level) ob_end_flush();
  $html_of_page = ob_get_clean();
Rob W
  • 9,134
  • 1
  • 30
  • 50