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 13, 2021: Fixed a compatibility issue with GPPA.
March 18, 2021: Fixed parsing of
title
anddescription
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.
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.
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.
Known Limitations
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.
Did this resource help you do something awesome with Gravity Forms?
Then you'll absolutely love Gravity Perks; a suite of 46+ essential add-ons for Gravity Forms with support you can count on.
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.
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.
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?
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,
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
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,
Hi Gravity Wiz
Love your work.
Is there a way of adding the loader to non-busted forms for visual consistency?
Best,
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,
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.
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,