Prevent WP-Cache from Caching index
« Best Free Online Banking for Web ProfessionalsCSS Cross-Browser Compatibility Tip »
A WordPress index page shouldn’t be cached by wp-cache the same as posts or other pages not as frequently updated. This 30 second fix gives you control to not cache / or /index.php on your blog. You can use this hack to disable caching anything you want.
First clear the cache from the WP-Cache Options Page. Then modify the wp_cache_is_rejected function.
NOTE: If anyone comes up with an improvement to this technique or a different/better implementation, please let me know so we can help with the development of an updated WP-Cache plugin!
function wp_cache_is_rejected($uri) {
global $cache_rejected_uri;
if(strstr($uri,'/wp-admin/') || $uri==='/' || strstr($uri,'/index.php'))
return true; //we don't allow cacheing wp-admin for security
foreach ($cache_rejected_uri as $expr) {
if (strlen($expr) > 0 && strstr($uri, $expr))
return true;
}
return false;
}
WP-Cache works by caching WordPress pages and storing them in a static file for serving future requests directly from the file rather than loading and compiling the whole PHP code and the building the page from the database…
The first is called at the very begining wp-cache-phase1.php when just few code has been compiled. The second wp-cache-phase2.php after all plugins have been executed. The first phase checks if the requested URL is already cached, if so it serves from the static file and finishes. The second phase stores the generated page in a static file for further request.
« Best Free Online Banking for Web Professionals
CSS Cross-Browser Compatibility Tip »
Please consider donating to support active development of the free software and articles here.![]()
The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect. Tim Berners-Lee
Thank you! It’s really funny because WP Super Cache (based on WP Cache) has an input field to accept rejected paths, but it’s impossible to input / or index.php into it!
is this mod-rewrite safe? Since if using pretty urls are being used everything goes to index.php, will it really disable just a home page?
Thanks. Looking forward to the updated WP-Cache plugin.
Hey AA… I’ve been reading your material for several months –you’ve helped a lot with my various projects along the way. Thank you!
I haven’t tested this plugin yet, but I presume Wp-Cache would also affect the post comments?
For example, 5 people have commented on post #39, but they’re seeing a cached page, so the latest comments would not be shown.
Is this correct?
It's very simple - you read the protocol and write the code. -Bill Joy
HTML | DCMI | GRDDL | XOXO | XDMP | XFN | DOM | XML | XHTML 1.1 Strict | CSS 2.1 | W3C | TLDP | WAI | DISA | ICSI | GIAC | SANS RR | GHOST | DEFCON | NIST | DHS CYBER | NIST | .:: Phrack Magazine ::.
↑ TOPExcept where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. HTTPD based on NCSA HTTPd
Nice. i looking for this solution.