[Hummingbird] Caldera and Hummingbird

Hi since caldera and hummingbird dont play well I would like to set the cache to be less then 12 hours, how can I do that? I was advised here: https://calderaforms.com/doc/caldera-forms-submission-rejected-token-invalid-mean/

When I set it at ->browser caching -> configure to 6 hours it stays on 8 days…

  • Adam
    • Support Gorilla

    Hello Sytze

    I hope you’re well today and thank you for your question!

    I read the article that you shared and I think what they are suggesting is a bit different thing. They are referring to a “static cache” there and in case of Hummingbird that would mean the “Page Cache”, not the “Browser cache”. These are two separate things: the browser cache is a control of what and for how long is stored by user browser. But assets/resources that include query parameters/nonces as well as forms should be automatically excluded from such cache by browser.

    As for why the setting stays at 8 days even if you change it. The Hummingbird attempts to control these browser cache settings but it’s not always possible as it’s actually a server-side setting and on some servers the browser cache “life span” is actually “fixed” – a relevant server module simply doesn’t take into account that value. However, I think it shouldn’t be the issue and 8 days is a reasonable value.

    Instead, I’d start with “static cache” as they suggest (the “Page Cache” in Hummingbird). Unfortunately, there’s no way to change how long that cache lasts as it’s only regenerated once it’s cleared. But if this is indeed the reason of the issue, there should be a way out of it as well :slight_smile:

    First, it’d be best to confirm whether it’s the reason for the issue or not: on the “Hummingbird -> Caching -> Page Cache” deactivate the Page Cache, then clear your browser cache (or use Incognito Mode in browser) and check if the form is then working fine.

    If it is, that might confirm the Page Cache being the culprit and in such case it’d be suggested to exclude page(s) with Caldera form(s) from that cache which can be done in two ways:

    – on “Hummingbird -> Caching -> Page Cache” page there’s “Exclusions” option where you can specify the part of the URL of the site that should not be cached; for example if your form is on /contact page you can simply add /contact to the list (one entry per line) and no page with the “/contact” string in URL will be cached.

    – you can exclude entire page template too by adding

    define('DONOTCACHEPAGE', true);

    at the top of the template file; this is a bit different because it requires editing theme file(s) and will exclude from cache all the posts/pages that are using this specific template.

    That should help if “static cache” is indeed the culprit here. If not, we’ll need to investigate it further so let me know about results, please, and we’ll then see what to do next if necessary.

    Best regards,

    Adam

  • Sytze
    • WPMU DEV Initiate

    Thanks for the answer, after clearing the cache the form works fine. The thing is that the form is on all of the pages. So in this cache hummingbird would be the solution for me, that is what you are saying right?

    Is there no way to automatically clear the cache with a time limit? If I turn it off the page is loading to slow and I will loose my client.

    I can’t imagine there is no solution for this.

  • Predrag Dubajic
    • Support

    Hi Sytze,

    At the moment there’s no such option to be done directly from Hummingbird settings, but it’s something I discussed with devs and we have add it on plugin to-do list :slight_smile:

    For now it would require using Hummingbird API to clear the cache at the set time, adding something like this in your child theme“>child theme functions.php or as mu-plugin should do the trick:

    add_action( 'clear_cache_cron', 'clear_cache' );

    function clear_cache() {
    do_action( 'wphb_clear_page_cache' );
    }

    if ( ! wp_next_scheduled ( 'clear_cache_cron' ) ) {
    wp_schedule_event( time(), 'twicedaily', 'clear_cache_cron' );
    }

    You can read more about setting desired times by using wp_schedule_event function here:

    https://codex.wordpress.org/Function_Reference/wp_schedule_event

    Best regards,

    Predrag

  • Predrag Dubajic
    • Support

    Hi Sytze,

    If you’re adding it as mu-plugin make sure to add PHP opening tag <?php

    Code would look like this:

    <?php
    add_action( 'clear_cache_cron', 'clear_cache' );

    function clear_cache() {
    do_action( 'wphb_clear_page_cache' );
    }

    if ( ! wp_next_scheduled ( 'clear_cache_cron' ) ) {
    wp_schedule_event( time(), 'twicedaily', 'clear_cache_cron' );
    }

    Best regards,

    Predrag

  • Adam
    • Support Gorilla

    Hi Sytze

    First of all, you should see how those forms behave now – if they are working fine. The other thing to check is to simply go to the “Hummingbird Pro -> Caching” page and there’s an information at the top about the number of pages currently cached. If the code is working fine you should notice how this number goes up (as the pages are added to cache “on the fly” when there are visitors to the site) and then go significantly down two times a day, around the same time each day.

    Then, there’s another option that you can use. On the “Hummingbird Pro -> Caching -> Page Caching” page please enable the “Enable debug log” option. This will also show a “download logs” button there so check that log from time to time and you should notice information there about cache being cleared.

    Best regards,

    Adam