Cache Busting with Gravity Forms

December 21, 2023: Fixed issue where Gravity Forms' default script event was not triggered for forms that did not have Cache Buster enabled.

September 8, 2023: Fixed moderate security issue.

October 25, 2022: Added support for enabling Cache Buster globally with form-specific exclusions.

July 21, 2022: Added support for using Cache Buster with WPML!

April 20, 2022: Added support for using Cache Buster with Nested Forms!

November 23, 2021: Fixed an issue where Save & Continue links generated by a form using Cache Buster would not be correct.

April 27, 2021: Fixed an issue with GF 2.5 and default Checkbox fields values.

April 27, 2021: Fixed an issue where field values were not passed properly to Gravity Forms.

April 13, 2021: Fixed a compatibility issue with GPPA.

March 18, 2021: Fixed parsing of title and description boolean values in shortcodes.

March 15, 2021: Fixed an issue where Cache Buster would not display a form's title.

October 1, 2020: Migrated snippet to the Snippet Library.

September 14, 2020: Added support for passing URL parameters.

Overview

I think if there’s one thing everyone in the WordPress community agrees on, it’s this: caching is awesome. It improves the performance of your site and reduces the bandwidth required to load pages and files. WordPress-specific hosting providers typically cache pages by default, and if you’re managing your own server you can add any number of plugins, such as WP Super Cache, W3 Total Cache, and many more that can immediately improve page load times. If you aren’t taking advantage of caching on your site, you should.

If you use caching on your site, you should know that it can sometimes cause unexpected side effects with Gravity Forms. This can be further compounded when using our Perks, like Populate Anything, Nested Forms, and Limit Choices. To avoid this, it is recommended to bypass the cache on Gravity Forms with dynamic features.

One solution for this is to simply exclude those pages from the cache, but you lose the benefits of page caching. A better solution is to only bypass the cache for the form itself, and we cooked up a Cache Buster plugin to do just that.

It loads the form via AJAX (not to be confused with submitting the form via AJAX), bypassing the WordPress cache for the form only. This allows the page cache, and the performance boost that goes with it, to remain intact.

  1. Overview
  2. Using the Plugin
    1. Prerequisites
    2. Using the Shortcode
    3. Apply to All Forms
    4. Known Limitations
  3. Fresh Forms for Gravity

Using the Plugin

Prerequisites

Confirm that you have Gravity Forms installed and activated and that you’ve installed and activated the plugin.

Using the Shortcode

When adding a form to a post or page via the [gravityforms] shortcode, simply add the “cachebuster” parameter:

[gravityforms id="123" cachebuster="1"]

The form will then load via AJAX , bypassing the WordPress cache.

See our in-depth guide on Gravity Forms Shortcodes for more information on the shortcodes you might wish to utilise with Cache Buster as well as the other shortcode possibilities.

Static forms that don’t use dynamic features are safe to leave cached!

Apply to All Forms

If you would rather apply the Cache Buster to every form on the page, you can do so by adding the following line to your theme’s functions.php file.

add_filter( 'gfcb_enable_cache_buster', '__return_true' );

The Cache Buster will now automatically apply to every form on your site that is loaded via a shortcode. Forms loaded via the Gravity Forms Block or using the gravity_form() method will not be cache-busted. If you’d like support for this, let us know in the comments!

Known Limitations

  • Cache Buster only works with forms loaded via the [gravityforms] shortcode – even when the gfcb_enable_cache_buster filter is used to apply to all forms.
  • Cache Buster does not work with single File Upload fields due to browser security. It does work with Multi-file Upload fields since they upload via AJAX.

Fresh Forms for Gravity

Another solution for automatically bypassing the cache is Fresh Forms for Gravity. It supports most of the caching plugins out there and requires no setup. Simply install it and your forms will be excluded from the cache.

Comments

  1. Rajon Ahmed
    Rajon Ahmed August 26, 2023 at 12:56 pm

    Hello, Today, I encountered a challenging situation on Upwork. A client gave me a 1-star rating and an unfavorable review due to issues with the Gravity Form not meeting their expectations. I made efforts to explain that the problem wasn’t my fault. I even utilized JavaScript to prevent an unintended auto-scrolling effect upon form submission. Initially, this approach was successful. However, the client later reported that the forms weren’t displaying up-to-date data. Consequently, I decided to install a plugin to address this issue, which unfortunately led to the form reverting to its auto-scrolling behavior.

    I believe it’s crucial to address this matter to prevent other freelancers from facing similar negative experiences in the future. The plugin’s presence seems to interfere with various filters, such as:

    1. add_filter( ‘gform_confirmation_anchor’, ‘__return_false’ );
    2. add_filter( ‘gform_confirmation_anchor_2’, ‘__return_false’ );
    Reply
    1. Samuel Bassah
      Samuel Bassah Staff August 28, 2023 at 9:38 am

      Hi Rajon,

      We’ll need you to submit a support ticket for this, so our developers can look into the issue. If you have an active Gravity Perks license, please submit the support ticket, so we can look into this further.

      Best,

  2. Mark Pfaff
    Mark Pfaff March 30, 2023 at 3:16 pm

    We installed this and it seemed to work, then a majority of our forms disappeared the next day. We disabled the plugin and they immediatly came back. None of the forms that dissappeared were using your shortcode parameter cachebuster=”1″ they were standard gravity form shortcodes.

    We’re using WP Rocket with WP Engine hosting. All plugins and WordPress up to date. I’m going to try to test this on a staging server to see if I can reproduce it but have you seen this before? Any ideas? We can’t use the plugin on our site so once I get a staging server setup I’ll try again and send a link.

    Reply
    1. David Smith
      David Smith Staff March 30, 2023 at 10:24 pm

      Hey Mark, we’ve seen one other report of this but that user wasn’t able to recreate it either. Please do get that staging site setup and and let me know if it happens again. We’ll be happy to dig in.

  3. Marian
    Marian December 12, 2022 at 4:14 am

    Hi there, this plugin does not work correctly with the {embed_url} merge tag (returns admin-ajax in the tag). Is there a workaround for this?

    Reply
    1. Dario Space
      Dario Space Staff December 12, 2022 at 12:18 pm

      Hi Marian,

      When testing locally, it works as expected. We’ll have to take a look at your setup to be able to assist you. If you have an active Gravity Perks license, you can get in touch with us via our support form.

      Cheers,

  4. Danny
    Danny October 22, 2022 at 10:14 am

    Hello there

    After lots of conflict testing, I’ve discovered that this prevents PayPal working well. At the moment when users complete payment, they cannot be redirected to my site because I use the code below: “add_filter( ‘gfcb_enable_cache_buster’, ‘__return_true’ );”

    It is very useful being able to apply this to all forms, I have 200+. Please can you let me know how I can apply to all and also exclude form 285 and form 77? Thanks!

    Danny

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff October 24, 2022 at 6:14 am

      Hi Danny,

      This will require some customization to the snippet. However, can you try and download the latest version of the Plugin above and see if it resolves the issue? If that doesn’t help, then we’ll need you to submit a support ticket. If you have an active Pro Gravity Perks license, you can get in touch with us via the support form so we can forward your request to our developers to see if support for using Paypal can be added.

      Best,

  5. B2
    B2 July 19, 2022 at 9:21 am

    Hi Gravity Wiz

    Love your work.

    Is there a way of adding the loader to non-busted forms for visual consistency?

    Best,

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff July 19, 2022 at 9:26 am

      Hi,

      I’m guessing this should be possible with some custom codes. If you have an active Gravity Perks Pro License, you can get in touch with us via our support form so we can assist you further.

      Best,

  6. sina
    sina May 2, 2022 at 12:56 pm

    Hi, I am using gravity nested form. The problem is that I put a field for dynamic evaluation. If I change the value of that field and the user form is not sent, the new value will not replace the previous one and they can abuse this.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff May 2, 2022 at 1:10 pm

      Hi Sina,

      This isn’t a known issue. We’ll need to dig into this further to determine what’s happening. If you have an active Gravity Perks license, can you get in touch with us via our support form, so we can take a closer look at your setup. In the meantime you may want to check if you’re using the latest version of the Caching buster plugin, and if not you can download the latest version here and update it.

      Best,

  7. Denis Mccaul
    Denis Mccaul April 13, 2022 at 1:09 pm

    Samuel in support helped me today with the Cache Buster, he said the developers have resolved the issue with Stripe in the latest version of the plugin. I tested it on a form that uses the Stripe addon and it worked fine in test mode. So may be worth revisiting for those who tried it before. It took 3 seconds off the page load time for me when I was able to use Varnish again. I previously could not have Varnish on the page (had used an exclusion rule) as it was stopping the child form from submitting to the parent form.

    Reply
  8. Fabrizio
    Fabrizio March 22, 2022 at 6:40 am

    Hi We have embed the form in a post and in the form we have two hidden fields with the following default value: {embed_post:post_title} {custom_field:crm_course} The problem is that if we activate Cache Busting the value for these two hidden fields is empty, so the form doesn’t get the values from the post. Please have you any idea about the reason of this issue? Thanks

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff March 22, 2022 at 8:51 am

      Hi Fabrizio,

      I’m not really sure what’s happening but if you have an active Gravity Perks License, you can get in touch with us via our support form and we’ll be happy to dig into this furhter.

      Best,

    1. Dario Space
      Dario Space Staff March 16, 2022 at 3:09 pm

      Hi Jocelyn,

      When testing locally it seems to work as expected in PHP 8.0. You can run a conflict test to check if any other plugins are conflicting with Gravity Forms. If not and if you have any further questions and you have an active license, you can get in touch with us via our support form.​ to dig into this.

      Best,

  9. lewis rowlands
    lewis rowlands March 7, 2022 at 12:13 pm

    I have realised this also doesnt work with paypal checkout aswell as stripe. I know you have messaged people saying send in a ticket. I dont mind paying for gravity perks to get this fixed but I want to know if you can get this to work on stripe and/or paypal first thankyou.

    Reply
    1. Dario Space
      Dario Space Staff March 7, 2022 at 1:07 pm

      Hi Lewis,

      From what I understand this is a limitation from Gravity Forms, caching, and how Payment gateways handle the data. I can confirm this can be fixed. We need to dig into each issue as an individual case.

      Best,

  10. lewis rowlands
    lewis rowlands March 6, 2022 at 12:20 pm

    Hello did you fix the issue with the gravityforms stripe addon? I thought id found the answer to my problems but stripe isnt working :-(

    Reply
  11. lewis rowlands
    lewis rowlands March 6, 2022 at 11:19 am

    Is there anyway for the ajax loader to loop, my form is quite large and takes a while to load on the page, the ajax loader doesnt loop so it looks like the page is blank.

    Reply
    1. Dario Space
      Dario Space Staff March 7, 2022 at 8:11 am

      Hi Lewis,

      This will require some digging. If you have a Gravity Perks license, reach out via the support form so we can assist you further with this.

      Best,

  12. Bet Hannon
    Bet Hannon January 7, 2022 at 10:35 am

    I’m not seeing any info about how to implement cache busting on a form that is embedded on the page via the Gravity Forms BLOCK versus a shortcode. Is there a way to do this when forms are put on the page with the block?

    Also, I see where other people had issues with the Stripe add-on as we did. Is there any info about that you can provide other than asking us to submit a support ticket?

    Reply
  13. Fabrizio
    Fabrizio December 9, 2021 at 4:57 am

    Hi my form has an hidden field that is populated with the value of a post Custom Field. With Gravity Forms Cache Buster active, the form doesn’t get the value of Custom Field in the post. Any suggestion? Thanks Fabrizio

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff December 22, 2021 at 5:52 am

      Hi Fabrizo,

      We’ll have to dig into this further to determine what’s happening. If you have an active Gravity Perks License, you can get in touch with us via our support form with an export of the form so we run some tests with it on our end.

      Best,

  14. Melissa Carney
    Melissa Carney September 5, 2021 at 11:27 pm

    Hi, I use Gravity Flow to enable the user to return to a partially filled in form (Gravity Forms Partial Entries) but if the user is not logged in, the form is not filled in when they return to it. If I use your plugin, the form is filled in (great, thankyou!). However, if I have your plugin installed, it interferes with the Gravity Flow reminder notifications for partially filled in forms (I can live with this as I have a work around in place for now) and more seriously it prevents the form from submitting correctly for Android users. The form actually submits but the user is not taken to the thank you page and form appears to endlessly load. This is causing great concern to our customers and they are trying to submit multiple applications as a result. I have reached out to Gravity Flow support to see if they can help with regards to the caching – but no luck as you can imagine. Can you please help?

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff September 6, 2021 at 10:13 am

      Hi Melissa,

      Unfortunately, we can’t really tell why this is happening without troubleshooting this further. If you have an active Gravity Perks license, you can get in touch with us with your account email address via our support form so we can dig into this issue. For now, I will suggest you run a conflict test to check if another plugin may be causing this. Here are instructions for how to run a theme/plugin conflict test:

      https://gravitywiz.com/documentation/help-us-help-you/#2-run-a-theme-plugin-conflict-test

      Best,

  15. Jesper Johansen
    Jesper Johansen August 19, 2021 at 6:18 am

    I noticed an incompatibility/bug with WPML. When using this plugin, WPML cannot update language in form on first pageview after language change. Needs a page refresh before form content is purged.

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff August 19, 2021 at 7:53 am

      Hi Jesper,

      If you have an active Gravity Perks License, you can get in touch with us via our support form with your account email address and we’ll be happy to dig into this further.

      Best,

  16. John
    John July 23, 2021 at 7:21 am

    Hello guys!

    Thanks for this! I’m trying it in a site now.

    It’s working great!

    The only thing that is happening is that I have 2 checkboxes already marked in the form’s settings, that is, when loading the form, these checkboxes already appear selected. But, when using Cache Buster, these checkboxes load unchecked. Any ideas?

    Cheers

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff July 23, 2021 at 8:03 am

      Hi John,

      I’m passing this over to our developers to take a look into this. We’ll update this comment when the issue has been resolved.

      Best,

    2. John
      John July 23, 2021 at 10:46 am

      Hello Samuel! Thanks

      Another situation I’m seeing is: fields which uses merge tags to populate its values aren’t working also

      Best :)

    3. Dario Space
      Dario Space Staff July 23, 2021 at 11:15 am

      Hi John,

      Thanks for the heads up. I wasn’t able to reproduce this issue locally. If you have an active Gravity Perks license, you can get in touch with us via our support form with your account email, so we see how best we can assist you.

      Best,

  17. Melissa Rachael Carney
    Melissa Rachael Carney May 12, 2021 at 2:56 am

    Hi, My forms that are using the cache buster setting will not load since the updating to the latest version of Gravity Forms. Have you had any other reports of this? Many thanks Mel

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff May 12, 2021 at 6:51 am

      Hi Melissa,

      Thanks for letting us know. I am forwarding this to our developers to work on a fix. We’ll update this comment when the fix is ready.

      Best,

    2. Samuel Bassah
      Samuel Bassah Staff May 14, 2021 at 11:11 am

      Hi Melissa,

      After further testing on our end, the cache buster works without any issue on Gravity Forms 2.5. I was only able to recreate the issue with one particular form but when I created that form, I was unable to recreate the issue on the new form.

      This appears not to be an issue with the snippet but a form-specific issue. If you have a Gravity Perks License, you can get in touch with us via our support form so we can dig into this further.

      Best,

  18. Melissa Carney
    Melissa Carney March 16, 2021 at 6:37 pm

    Hi,

    I have just installed your cache busting plugin. Thank you – I had tried everything else still couldn’t return to a partially filled form if I wasn’t logged in. I don’t want to display the title nor description on my form, so my gravity form shortcode previously had set title and description to false.

    [gravityform id="1" title="false" description="false" cachebuster="1"]

    This is working on Chrome (desktop) but it is still showing the title on Safari (iPhone) and Firefox(desktop). Am I using the shortcode correctly?

    Many thanks

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff March 17, 2021 at 6:42 am

      Hi Melissa,

      Thanks for bringing this to our attention. I’ll pass this over to our developers to take a look into this. That said, as a workaround, you can use the shortcode without the title and description parameter. Something like this [gravityform id="1" cachebuster="1"], should do the trick and ensure the Title and Description aren’t displayed on the form.

      Best,

    1. Samuel Bassah
      Samuel Bassah Staff March 11, 2021 at 6:53 am

      Hi Don,

      I am unable to recreate the issue you’re experiencing. The Live Merge tags works as expected when I tested it on my end. If you’re a Gravity Perks customer, you can get in touch via our support form so we can assist you further.

      Best,

  19. TomazHurtz
    TomazHurtz November 19, 2020 at 5:31 pm

    Does not work with Gravity Forms Stripe…

    When using this and stripe v3.85, the cache buster breaks stripe such that the credit card field is hidden – I’m guessing it interferes with the stripe iframe from showing…

    Disabling the cache buster allows the stripe field to show again, but then the form totals are wrong because of the cache !

    Reply
    1. Samuel Bassah
      Samuel Bassah Staff November 20, 2020 at 7:03 am

      Hi TomazHurtz,

      You’re right the cache buster interferes with the display of the credit card field. If you are a Gravity Perks customer with an Advanced or Pro license, drop us a line and we can look into adding support for this.

      Best,

    1. Ryan Donovan
      Ryan Donovan September 27, 2020 at 11:29 pm

      Hello Zunaid, Thank you for that report. Let me get a request in to get this resolved. In the mean time, you can add the snippet version to your themes functions.php file and see if that works for you. Will update when resolved. 😀

    2. Ryan Donovan
      Ryan Donovan October 1, 2020 at 9:55 am

      Hello Zunaid, Wanted to update you on this one as we have resolved this issue. Please go ahead and click the download button again and you should be all set. 😃

  20. richard Furst
    richard Furst June 13, 2020 at 6:48 pm

    Work Well! Just not working with a {embed_url} conformation redirect, it results in a blank page. Any workaround?

    Thanks

    Reply
  21. Scot MacDonald
    Scot MacDonald June 2, 2020 at 10:33 am

    Right, I’m aware of that, but are there some minimum requirements for PHP, for example, for this to be effective?

    Reply
    1. Scott Ryer
      Scott Ryer Staff June 2, 2020 at 11:41 am

      Hi Scot,

      I just ran a version check, and this plugin shows no issues with PHP 5.6 or greater.

    1. Ryan Donovan
      Ryan Donovan June 2, 2020 at 10:30 am

      Hey Scot, Please just confirm that you have Gravity Forms installed and activated and that you’ve installed and activated the plugin or cache buster code listed above.😃

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Download Plugin

Cache Busting with Gravity Forms

This field is for validation purposes and should be left unchanged.