Overview

Gravity Forms is a popular WordPress plugin, which allows the creation of both simple and complex forms as well as conditional logic, payment integration and more. For most pages with forms (including ones protected by CAPTCHA), they work seamlessly with page caching plugins such as W3 Total Cache.

However, if you have a  Multi-File Upload enabled, this will cause issues with all page caching plugins. Users may see errors such as:

Error: 403, Message: Your session has expired. Please refresh the page and try again

This is because the multi-upload part of the form uses an embedded security code (called a nonce) to protect the URL from malicious use. The standard WordPress nonce only has a lifetime of 24 hours, meaning that if a cached copy of the form

Fixes

Fix 1: Use single file uploads

If your form only requires a single file, the easiest fix is to disable the ability to upload multiple files. Within the Gravity Forms form, simply deselect the Multi-File Upload option:

Gravity Forms: Multiple File Uploads with Page Caching

Fix 2: Exclude the form pages from cache

Where you require multi-file uploads, the next easiest solution is simply to exclude the URL’s from being cached (eg /contact). However, this means that every visit to the form page requires WordPress to render it and it will be slower than the cached pages.

The method of exclusion will vary based on the caching plugin used but normally well documented for each of the popular ones.

Fix 3: Use a cache busting plugin

This is the more complicated path, as it requires another plugin to be installed. However, it means that the page itself still remains cached for performance and the form remains working for Multi-File Uploads.

At present, only one plugin exists and is part of the Gravity Wiz Spellbook plugin. The Cache Buster plugin then loads the entire form as an AJAX call, so it will always be up-to-date with a fresh nonce.

For most page builders and even the standard WordPress block editor, this also requires code changes to the functions.php file within your theme to implement. We don’t recommend this option unless the form is embedded on many pages and critical that it remains this way.

Was this article helpful?

Related Articles