Some posts are requested through Ajax.

// Filename: ajax-posts.php
require_once "wp-load.php";
echo my_get_post($_GET["id"]);

How can I make theese Ajax requests cacheable by W3 Total Cache?

  • 4
    For something like this, would it be more effective to use the Wordpress Transients API and cache the requests that way? Also, is there a specific reason you're not routing the ajax requests through admin-ajax.php and using a wp_ajax_ action instead of including wp-load.php? I'm not sure what your set-up or intent is with this and I don't wnat to steer you wrong, so maybe someone else can chime in, too.
    – Eric Allen
    Commented Oct 4, 2012 at 4:00

1 Answer 1


Short answer: You can't. Getting W3 Total Cache to talk to a non-WP call in manor listed above isn't (easily) possible. I completely agree with @allenericr comments. The Transients API is very straight forward and quite simple to implement. In addition, @allenericr, comment on using admin-ajax.php is also spot on. It's not sure it's best practices to just include wp-load and call it good (sounds like a big security hole).

Not the answer you're looking for? Browse other questions tagged or ask your own question.