• Resolved clay123

    (@clay123)


    Hello and thanks for providing a simple and neat solution to a complex problem. I recently installed this plugin on a website that uses WP Super Cache (WPSC) and noticed that the consent message is not appearing on some pages, those appear to have been cached when viewed by a user that had already offered consent. Is there a way to load this plugin before or outside of the cache?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Rick Hellewell

    (@rhellewellgmailcom)

    Thanks for the nice comments. (Reviews are nice too πŸ™‚

    I will try to test this, but wondering if you have cleared your local cache when testing this. Or, try it with a ‘private’ browser, which will ‘look’ like a new visitor.

    The code in the program looks for the cookie named ‘cookieconsent_status’, and if not found, will display the cookie banner. If the cookie is accepted (the ‘ok’ is clicked on the banner) that cookie is saved in the local browser. The cookie has an expiration of a year, so the user won’t see it again until a year from acceptance (unless the user or their browser clears the cookies).

    So:
    – does your browser clear all cookies on exit? That would display the banner again.
    – if you accept the banner, is the cookie stored (use developer tools to see)?
    – do you have some cookie-clearing/blocking set in your browser? (Using a ‘private’ browser window will show you the banner once, then you won’t see it again on that private session).

    I’ll test with that caching plugin, suspect it might be a local browser/caching/cookie-blocking issue.

    Let me know. Thanks…Rick…

    Plugin Author Rick Hellewell

    (@rhellewellgmailcom)

    Found these threads in the support area of the WP Super Cache plugin:

    https://wordpress.org/support/topic/php-cookies-doesnt-work-with-wp-super-cache/’

    And this article: https://odd.blog/2018/07/20/wp-super-cache-and-cookie-banners/

    Basically, the issue is that the caching plugin is serving up HTML pages, rather than letting WP generate the page. And the static HTML page doesn’t contain the cookie-checking code of my plugin (which is a PHP file that WP executes).

    So that is why you don’t see the consent banner – it isn’t in the static HTML pages that the cache plugin uses (instead of the WP-PHP-generated pages).

    The above links (especially the second one) seem to indicate only two solutions: a special WP Super Cache add-in, or some client-side JS code to check cookie. And that second solution is not easy – what if, for example, the visitor disables local JS?

    A better solution would be if the WP Super Cache plugin allowed you to specify specific cookies that, if not set, would disable cache for that visitor request.

    But as it stands now, my plugin won’t ever get the chance to display the banner, because the caching plugin is not letting WP (and my plugin) generate the page.

    Thread Starter clay123

    (@clay123)

    Wow, thanks for the amazing follow up! Would there be any way that your plugin could be used within a shortcode? Inside WP Super Cache you can install dynamic shortcodes,

    The Xoogu Dynamic Shortcodes plugin for WP Super Cache enables you to choose shortcodes that should be processed dynamically on every page load. This can be useful if you have a shortcode that needs to display changing information, such as geo-targeted content, short timescale based content, or visitor specific content.

    I have used this to call some geo related shortcodes before and can verify it doesn’t cache these.

    Plugin Author Rick Hellewell

    (@rhellewellgmailcom)

    Not clear how a shortcode would work if WPSC is sending out the HTML page, not the WP-generated page (which would process the shortcode). But my understanding on how WPSC works is slim.

    Research seems to indicate that the following code might work. Could you place it in your functions.php file to test it with your installation? Clear cache, etc. to test it well. (In Developer Tools, look at the Storage tab and delete the cookie, then reload and see if the banner occurs.)

    function add_wpsc_cookie() {
    do_action( 'wpsc_add_cookie', 'cookieconsent_status' );
    }
    add_action( 'init', 'add_wpsc_cookie' );

    Appreciate your test of this. If it works for you, I can add this to the next version.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Issue with WP Super Cache WPSC’ is closed to new replies.