Troubleshooting Regenerate Thumbnails: Common Conflicts with Caching and Offloaded Media
Content
Users of the popular Regenerate Thumbnails plugin sometimes encounter issues when it interacts with other technologies like server-level caching (e.g., Varnish) or media offloading plugins (e.g., WP Offload S3/Lite). This guide explains why these conflicts happen and provides the most common solutions to get your thumbnails regenerating smoothly.
Common Problem 1: The "Cookie nonce is invalid" Error with Varnish Cache
This error occurs because the plugin's REST API requests, which are used to process regeneration in the background, are being blocked or altered by the Varnish cache. The security nonce (a number used once) that the plugin sends is not being recognized, halting the process.
How to Fix It:
- Configure Varnish to Bypass Cache for Admin Requests: The most effective solution is to configure your Varnish server to not cache requests originating from the WordPress admin area (wp-admin). This ensures the security nonces pass through correctly.
- Exclude the Plugin's API Endpoint: Work with your server administrator to add a rule in Varnish that excludes the Regenerate Thumbnails REST API endpoint from being cached.
Common Problem 2: Issues with Offloaded Media (S3, etc.)
Based on community reports, a fundamental limitation of the Regenerate Thumbnails plugin is that it only works on media files stored locally on your server. If you are using a plugin like WP Offload Media that removes files from your server after uploading them to a cloud storage bucket, Regenerate Thumbnails will have no local file to process and will fail.
How to Fix It:
- Temporarily Download Files: To use Regenerate Thumbnails, you must first have a local copy of the media file. This may require temporarily adjusting your offload plugin's settings to "Keep Files on Server" and then re-uploading or syncing the files you need to process. Always consult your offload plugin's documentation for the correct procedure, as this process varies.
- Use an Older Version (Temporary Workaround): Some users have reported that version 2.3.1 of Regenerate Thumbnails, which uses an older AJAX method instead of the REST API, may work better in certain multisite or complex server environments. It is important to note that the Regenerate Thumbnails team has stated there are no known security issues with this version, but it is no longer maintained. This should only be considered a temporary stopgap, not a permanent solution.
Key Takeaways
- Varnish/Caching Issues: Are often resolved by configuring the cache to bypass admin and API requests.
- Offloaded Media Issues: Are not a bug but a core limitation. The plugin requires local files to function.
- For problems specific to another plugin (like WP Offload Media), it is always best to also consult that plugin's support resources for their recommended way to handle local files.
Related Support Threads Support
-
Conflict with Offload S3 Since Rest APIhttps://wordpress.org/support/topic/conflict-with-offload-s3-since-rest-api/
-
Not Working With Varnish Cachehttps://wordpress.org/support/topic/not-working-with-varnish-cache/
-
Disable the S3 bucket URlhttps://wordpress.org/support/topic/disable-the-s3-bucket-url/
-
WP Offload Media with “Remove Local Media”https://wordpress.org/support/topic/wp-offload-media-with-remove-local-media/