WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
[resolved] Customize the "make users anonymous" feature? (2 posts)

  1. jondaley
    Member
    Posted 1 year ago #

    I have a site that is mostly anonymous (I use javascript to do the customized portions), and so I'd like to use the "make users anonymous to serve supercache files" feature, but I have one section that is entirely customized for each user, and so what I'd like is if the list of files that is forced to be not cached would override the remove cookie code.

    We wrote a while ago about the remove cookie function, and you were going to make it easier to customize that - did that ever happen?

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. jondaley
    Member
    Posted 1 year ago #

    I went back and found my old post:

    http://wordpress.org/support/topic/plugin-wp-super-cache-make-known-users-anonymous-breaks-autheticated-commenting?replies=8

    describing the new feature that was added. Though as I noted, it was broken at the time.
    http://wordpress.org/support/topic/plugin-wp-super-cache-make-known-users-anonymous-not-work?replies=4

    I worked on this today, and here is what I did:

    mkdir wp-content/themes/paleo/supercache_plugins
    edit wp-content/wp-cache-config.php:
    look for $wp_cache_plugins_dir = ...;
    and replace with
    $wp_cache_plugins_dir = ABSPATH . 'wp-content/themes/paleo/supercache_plugins';

    Made a new file in the supercache_plugins directory, named whatever you want:

    function paleo_force_nosupercache() {
      global $cache_rejected_uri; 
    
      if(wp_cache_is_rejected($_SERVER['REQUEST_URI']))
        return false;
      else
        return true;
    }
    add_cacheaction( 'wp_supercache_remove_cookies', 'paleo_force_nosupercache' );

    I didn't need to be able to enable this code via the supercache plugins page, but you can copy the _admin code from a provided plugin in wp-content/plugins/wp-super-cache/plugins if you need that behavior. I also didn't need any provided plugins, you would need to copy or symlink them if you need them.

    I wonder if this behavior should be in the core code, because if a user has put in a URL on the don't cache/rejected_uri list, they probably don't want it ever cached, even if the user is anonymous?

    I guess it isn't defined which setting takes priority.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic