• I’ve run into a dilemma: I would like to set up some of my widgets to only display if viewers have accepted the site privacy policy. I can do this by setting a conditional tag in Widget Logic: has_consent (‘privacy-policy’ ).

    This works perfectly with caching disabled. However, when I enable caching, that widget simply never appears, whether on refresh or after navigating to a different page, without disabling the cache. If a new visitor accepts the privacy policy, the page is reloads, but it just reloads the supercached file rather than actually refreshing. More concerningly, a viewer who already had the stored cookie indicating their consent still doesn’t see that widget at all.

    I assume that what’s happening is that the supercached files are storing a static version of the page without that widget, and nothing the visitor does can trigger a refresh. (Even leaving a comment probably won’t do it because comments are moderated, so the comment refresh doesn’t happen until I see and approve the comment.) The widget’s contents are HTML rather than JavaScript, but I’m suspecting that even if it were JavaScript, the widget itself would not load because of the caching issue.

    Is there a way to make this work short of just not having caching enabled? Super Cache produces some pretty dramatic speed improvements, so I’d rather not lose that.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 16 through 18 (of 18 total)
  • Thread Starter Ate Up With Motor

    (@ate-up-with-motor)

    Can you walk me through, in plain terms, the way your plugin is intended to work?

    Let’s say a first-time visitor arrives for the first time. Assuming WPSC Simple caching is enabled, are they still served a supercached page? If so, how does that supercached page treat page content that’s selectively enabled or disabled by conditional tags based on cookie values?

    As soon as a visitor lands, the GDPR plugin places its initial set of cookies and pops up the notification/consent banner. Once the user clicks the acceptance button, the GDPR plugin attempts to reload the page. (This is one of GDPR plugin’s configuration options.)

    When this happens, will the visitor then be treated as a known user and the page rebuilt (which would allow the conditional tags to run) rather than just refreshing the supercached version?

    Let’s say the same user leaves and then comes back the following day, still with the saved GDPR cookies. Will they be treated as a known user or will they be served a supercached page?

    I’m sorry to be dense — I don’t understand the code very well, so I have to think in terms of the underlying logic so I can figure out an appropriate way to test it that will be useful to both of us.

    (I really appreciate your help with this, by the way. This is very challenging for a non-developer!)

    We have 3 groups of visitors:

    1. Anonymous visitor ( first-time visitors or “empty cookies” )
    2. Consented visitor ( cookies contain “consent_types” or “allowed_cookies” )
    3. Logged user (know user in WPSC).

    Maybe, it isn’t described well, but I think that you understand.

    When anonymous visitor gets page, WPSC serves supercache file. All GDPR functions return false because GDPR cookie is empty (doesn’t exist or arrays consent_types/allowed_cookies are empty). If WPSC served page then initial cookie isn’t set (because GDPR plugin isn’t loaded – it isn’t an issue because JS will set cookie when anonymous visitor clicks on privacy banner).

    When anonymous visitor clicks on privacy banner then JS (GDPR plugin) makes ajax request which processes changes/set cookies (ajax request or JS can set cookie). Next step is reload and browser sends cookie via header. Our GPDR plugin decodes cookie content and WPSC serves/stores properly wp-cache file (WPSC doesn’t touch supercache file in this case). In cache directory, you will see two new files ( meta-wp-cache-….php and wp-cache-….php). These files contain page with “enabled content” (because GDPR functions return true based on cookie values). WP-Cache file is gzipped if it’s requested (WPSC makes only one cache-file variant based on request’s header).

    Consented visitor has saved cookie in browser (until he/she purges cache – default expiration for GDPR plugin is one year I think). Browser always sends cookie and our GDPR plugin will “decode cookie”. So, WPSC for consented visitors always stores/serves wp-cache files.

    Logged users should be excluded from caching when we merge PR #616. For now, they and consented visitors are overlapping. I’ve tried to make some workaround in our GDPR plugin which isn’t perfect, but we will improve it in the future.

    No problem, it’s good to we make test cases and find the weakest point in the code. I’ll have limited time in next week (or two weeks), maybe my replies will be little delayed.

    Thread Starter Ate Up With Motor

    (@ate-up-with-motor)

    Understood — thanks so much for spelling this out. Let me run some tests and see what kind of results I get. I’ll post here when I have some feedback.

Viewing 3 replies - 16 through 18 (of 18 total)

The topic ‘WP Super Cache and conditional tags’ is closed to new replies.