Here is what I ended up doing:
// Set disable cache for certain roles
add_action('init', 'add_custom_cookie_admin');
function add_custom_cookie_admin() {
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$thisrole = $current_user->roles[0];
if($thisrole !== 'subscriber') {
setcookie("disable_cache", $current_user->user_login, time()+43200, COOKIEPATH, COOKIE_DOMAIN);
}
}
}
// and then remove the cookie on logout
function clear_custom_cookie_on_logout() {
unset($_COOKIE["disable_cache"]);
setcookie( "disable_cache", '', time() - ( 15 * 60 ) );
}
add_action('wp_logout', 'clear_custom_cookie_on_logout');
And then I added this to my nginx cache:
if ($http_cookie ~* "disable_cache") {
set $skip_cache 1;
}
Related Posts:
- Optimize apache for WP use
- Nginx + WordPress + HHVM: Why isn’t Batcache working? Would Varnish help even more?
- Jetpack stats and caching strategy [closed]
- Scheduling doesn’t work due to caching?
- Sage theme caching issue on WPEngine
- W3 total cache – cache refresh programmatically [closed]
- Should I use Transient API to store HTML String, or Object?
- Caching: APC vs APCu vs OPcache
- Best way to show Dynamic Content on a Cached WordPress Site?
- Is define(‘WP_CACHE’, true) needed for object caching?
- Prevent WordPress from sending Cache-control http header
- Pros and Cons for high “expire time” on wp-super-cache or w3-total-cache? [closed]
- Limit cache size from W3 Total Cache [closed]
- Does a query executed through wpdb class get cached?
- Configuring WordPress for Amazon CloudFront Caching?
- Nginx FastCGI_Cache Vs PHP Caching
- Caching: Force fresh content for logged-in users (potentially by adding a query variable to the URL)
- Multiple WordPress sites eat up alot of RAM
- What exactly is an advanced object cache?
- Using a wildcard with delete_transient()
- Will I see a performance hit if I use native API calls like get_the_title() instead of $post->post_title?
- WordPress Browser Cache with W3-Total-Cache doesn’t show new posts [closed]
- Does a low traffic WordPress site need a caching plugin and a CDN
- Automatically Refresh WordPress Stylesheet
- wp_cache_set() or wp_cache_add()
- How to use cache with simplepie
- Fragment caching increasing database queries
- Can I force get_option to go back to the DB instead of cache?
- Which WordPress pages/URLs should never be cached?
- How to archive a wordpress site (make it read only)
- How to purge all transient caches?
- Stale cache handling with a persistent object cache
- Varnish + W3 Total Page Cache [closed]
- Are there any server requirements for WordPress transients to work properly?
- My WordPress site always displays a cached version of its homepage
- Writing a cache manifest file for a WordPress blog (app cache, offline web applications)
- W3 Total Cache doesn’t detect memcached [closed]
- Settings to get the most out of W3 Total Cache
- How to force content refresh of a page that has been loaded previously by the user? [closed]
- Help Pinpointing Source of Caching Issue
- How to clear cache without a plugin [closed]
- can’t see live version of style.css – is it web server caching?
- Want to enforce the visitor to load the new version of your stylesheets and scripts [closed]
- Cache issues with redis and nginx
- Can someone explain WordPress caching, and what’s the best in my scenario?
- Transient / object cache maximum key length [duplicate]
- Speed up WordPress
- wp-super-cache exclude file from caching
- APC object caching in combination Batcache/memcached page caching?
- Should the page cache be refreshed often? [closed]
- WordPress caching in development
- Plugin a specific cache functionality?
- What is difference between ‘Page Cache’ and ‘Object Cache’ in WordPress?
- W3 total Cache – Site with query strings
- Check if a user is connected and get is ID without fully loading wordpress
- Should I enable FastCGI on WordPress?
- Programmatically insert hierarchical terms & set terms for post causes glitch? [duplicate]
- Will caching WordPress affect session variables, custom filed updates and displaying images from a non wordpress table?
- Getting soft 404 errors (200 status) when caching plugins are enabled
- How to totally disable cache in WordPress?
- Automatically enabled caching in some hosting companies w/o visible plugin (Must use plugin)
- Database Cache and Object Cache Difference?
- Register script version not showing
- How to purge all transient caches?
- W3 Total Cache plugin integration
- PHP Code stuck in Cache [Memcached] [closed]
- When use a cache system with WordPress
- server load. $_SERVER[‘REMOTE_ADDR’] and $_SERVER[‘HTTP_HOST’] [closed]
- Optimizing Jetpack for WordPress [closed]
- Is it possible to save an entire piece of rendered HTML in a transient?
- Execute a piece of code also when the cached version of a page is served
- Method to make definitively static an abandoned WP blog
- How do I fetch feed info from cache instead of directly from feed?
- pass-protected pages and posts not protected after enter them 1 time
- Can a WordPress blog be entirely hosted on a CDN if cached?
- Static HTML page caching for large website [closed]
- To have WordPress interact with memcached it must be installed as a PHP extension?
- Transients are not expiring as expected in simple custom plugin
- WordPress caching issue
- Prevent installation of style.css cookies and file caching
- How can I revert to showing cached pages when no database connection is available? [closed]
- WP Super Cache Bug with Ubermenu
- How to speed up my site [duplicate]
- Problem with caching, W3TC [closed]
- Headway body classes and W3TC page cache conflict [closed]
- Reasonable Size Limit to options entry
- Is the object cached?
- How to find time last viewed?
- How to combine wordpress_logged_in cookies in one cookie?
- How can I cache the LearnDash quizzes on my server?
- WP Rocket Cache Lifespan – Never clear cache? [closed]
- Disable feed cache for custom RSS feed?
- How do I enable dynamic content in a theme cached with WP Super Cache?
- How to cache a different page version based on HTTP header?
- WP_Object_Cache for heavy WP_Query
- WordPress & Fastcgi proper setup?
- How to store or cache custom shopping cart data for every user’s session
- Live website is not showing the changes I’ve made [closed]
- How to decode wordpress transient cache stored in database?
- Hook an action when a transient is deleted ? Can’t get it to work!