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
descriptionboolean 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.
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
- Fresh Forms for Gravity
Using the Plugin
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.
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.