Website forms capture submitted data. If your form auto-populates or contains dynamically generated data, website form caching may create errors or display an old version of the form. You may want to exclude website forms from caching.
Caching is when your website saves pages as pre-assembled html so that they load much faster for the user. Instead of having to dynamically gather all the parts of the page or post from the database and check the theme for how to display them (fonts, colors, etc.), the page can be quickly delivered to the user. Generally speaking, caching websites is a very good idea.
Caching can cause issues with forms
Caching can be a plugin you add to your site and activate. But caching can also happen at the server level. Ask your web host or developer if this is turned on. You can also test for this using tools like this one.
But when a form is on the cached page, like a Gravity Form, then the cached version of the page may have captured some of the dynamically generated data from a previous submission. That’s a problem, especially if it’s data that the user doesn’t see. Like in hidden fields, or if it’s in a field that you are preventing the user from editing. For instance, you may be using a URL parameter to autopopulate an email field that the user doesn’t see.
Additionally if a page displaying a form is cached, the cache for that page is not automatically cleared when the form is updated. Generally, when you edit and save a page or post, the cache for that page is cleared. But this isn’t the case for editing an embedded form. You might edit the form, but users could still be seeing the old form until the cache expires or is cleared.
Having cached pages with forms doesn’t always create an issue, but it can. It can happen often enough that you’ll want to take precautions and make your form data as accurate as possible.
Why don’t forms plugins turn off caching automatically?
You might wonder: why don’t the plugin developers simply prevent caching of the pages that contain a form automatically? While this sounds like a good solution, it means less experienced website owners might not realize they could potentially exclude ALL their pages from caching. For instance, you have a newsletter signup near the bottom of every page, if all pages with forms were excluded, then no pages would be cached.
Additionally, problems with caching in forms mostly affect forms where the site owner has configured advanced dynamically populated fields. Not every form needs to be excluded from caching in the same way.
How to test for caching issues in form data
You may want to check your form submissions for any caching issues in dynamically created data. Export your entries to a CSV file and look for duplicated data on an entry that should be unique data. For instance, you have a hidden field on the form that gets dynamically populated by the logged in users’ username. You’d be looking for instances where the username on an entry was one submitted an earlier entry when it shouldn’t be.
What are some solutions?
The type of data you’re collecting and what you’re doing with it will factor into your solutions. If you aren’t collecting any dynamically generated data in your form fields, and the user can see and edit all the form fields, you might decide that it’s not worth it to try to exclude forms from caching.
Remember that it’s not just the page where the form itself appears that you need to be concerned with. You’ll also need to be concerned with what you’re doing with that submitted data. For instance, what if you are displaying the submissions, or using an API to send them to another platform.
Some Gravity Forms related plugins do a great job at clearing their caches (here’s looking at you, GravityView), but others may not. You’ll want to check on potential caching related issues. Then make a decision about whether to cache a form page or not.
If every form (or nearly every form) on the site has dynamic data and potential issues, you may want to globally exclude all forms from caching. Fresh Forms for Gravity is a free plugin from the WordPress plugin directory. It excludes Gravity Forms pages from all the major caching plugins, even when they are within major pagebuilders.
Gravity Wiz: Cache Busting
The Gravity Wiz team has created a plugin Cache Busting that will allow you to still cache the page a form is on, but exclude the form from caching. With this plugin, the form loads via AJAX, bypassing the site caching for the form only. This allows the page cache, and the performance boost that goes with it, to remain intact.
Custom Snippet for Gravity Forms & WP Rocket
Our team only ever uses Gravity Forms with the WP Rocket caching plugin. For clients who need to exclude all forms pages from caching, we have opted for a custom coded solution. It was adapted from ideas provided by the WP Rocket team. Use this snippet at your own risk!
But caching doesn’t have to be all or nothing! If a few forms need to be excluded, you can usually fine-tune your caching rules in your caching plugin or your hosting. If your site is using server caching, you’ll need to consult your hosting support about how to add never cache rules.
Have questions? Don’t hesitate to reach out!
Never miss another article from us. Sign up today to receive our monthly newsletter to learn more about website accessibility, best content practices, and more.