Support » Plugin: GDPR Cookie Compliance (CCPA ready) » wp-supercache handling proposal

  • Resolved pik256


    GDPR Cookie compliance plugin use supercache handle wpsc_add_cookie to register cookies and make cache to differentiate cache files on cookie value. However, this approach has a weakness: on presence of cookie_notice_accepted cookie wp-supercache plugin does not store generated page as a static file (index.html, index-https.html, …-mobile.html, etc.) but generates a php file with pseudo-random name (containing encoded cookie value) and meta file for each cookie value. This prevents serving static files in expert cache mode because only supercache php script can calculate a valid name, read and serve cache file.
    However, in the simpliest case we have only one cookie with one value: cookie_notice_accepted: true. So, instead of creating random files, it would be far better to instruct wp-supercache to create another variant of a static html file for a page with this cookie name and value. I know the plugin premium version uses another cookie hu-consent, but in that case probably there are only a few more values and the solution would be slightly more complicated.
    My proposal consists of a few lines of code, first to deregister cookie registered by GDPR plugin, next to instruct supercache to use another variant of a static file for a page with the cookie:

    ;1. deregister cookie name from supercache
    function wpsc_delete_cookie_notice_check() {
      do_action( 'wpsc_delete_cookie', 'cookie_notice_accepted' );
    add_action( 'init', 'wpsc_delete_cookie_notice_check', 20 );
    ;2. Set the name variant
    function wp_super_cache_cookie_notice_check( $extra_str ) {
    	if ( isset( $_COOKIE['cookie_notice_accepted'] ) && 'true' === $_COOKIE['cookie_notice_accepted'] ) $extra_str .= '-cookied';
    	return $extra_str;
    add_action( 'supercache_filename_str', 'wp_super_cache_cookie_notice_check' );

    Now, in my situation wp-supercache creates 2 variants of a static page file: index-https.html for users without a cookie and index-https-cookied.html for these with the cookie.
    This works both in a simple cache mode and in an expert mode with rewrite rules for direct serving pages without php.

    Should this method be incorporated into plugin code, the first part is unnecessary, together with current init action in plugin code (do_action( ‘wpsc_add_cookie’, ‘cookie_notice_accepted’ )), what need to be removed. The whole code is smaller and we can use expert cache mode.

    • This topic was modified 8 months, 3 weeks ago by pik256.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Moove Agency


    Hi @pik256,

    Thanks for using our plugins.
    Our implementation shouldn’t be affected by supercache plugin, as we are using JavaScript to insert cookies via AJAX. The cookie scripts specified in GDPR Cookie Compliance settings are not visible in the source code, and are not part of the HTML generated by supercache as the HTML will be extended dynamically.
    All you need to do is to exclude the moove_gdpr_popup cookie from supercache plugin as this is the cookie where we are storing the user consent.

    If you need advanced setup, you can find all the available hooks in GDPR Cookie Compliance -> Help, Hooks, Filters & Shortcodes

    Hope this helps.

    Thread Starter pik256


    Oops, I should have posted it at another plugin forum. Sorry for the mistake.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp-supercache handling proposal’ is closed to new replies.