A caching plugin generates static HTML pages of your website and saves it on your server. Each time a user tries to access your website, your caching plugin serves up the lighter HTML page instead of processing the comparatively heavier WordPress PHP scripts. In a few words by using a cache plugin you can bypass the PHP server-side creation of the page and provide the user with a saved version of the page implementing load times considerably.
WP Rocket (suggested option)
If you’re running Uncode we’d recommend giving WP Rocket a try first. WP Rocket is more than just a caching solution and it also enables you to minify your site’s files. Setting up WP Rocket is amazingly simple, you’ll just need to read about the tool’s basic settings or ask their awesome support, and it runs perfectly alongside Uncode right out of the box (we recommend using at least WP Rocket 3.1):
Free alternative cache plugins
As for WP Rocket please activate the Uncode → Theme Options → Performances → Asynchronous Adaptive Image System. Note that the same guidelines are valid for other cache plugins as well you set the same settings for the JS files to exclude from minifying.
Another good free plugin alternative that you can use is WP Fastest Cache. When you use this plugin deactivate the option Settings Render → Blocking Js and as for Breeze exclude the above files from the tab Exclude → Exclude JS. As for WP Rocket and Breeze plugins please activate the Asynchronous Adaptive Image System of Uncode.
Cache plugins, WordPress Nonces and Cache Lifespan
In Uncode 1.9.0 and later we have introduced security improvements and we must therefore pay attention to the right settings for WordPress Nonces. Nonces are security tokens in WordPress. Nonces can only be used once (hence “nonce”), and they are only valid for a certain length of time. On a cached page, the nonce can expire in the background while its ID is still present in the HTML source code of the page. If that happens, the HTML source is referencing an invalid nonce and things break. This can affect all kinds of functionality, from form validation to not working Async Adaptive Images, and a lot more.
- Set cache lifespan to 10 hours or less with WP Rocket: after the cache gets cleared, the HTML gets regenerated and references a correct nonce again. Hence, when your WordPress setup (theme, plugins) operates with nonces, the only way to keep them updated on cached pages is to set your Cache lifespan option in WP Rocket to a value below 12 hours; 10 hours would be a starting point and it works fine screenshot , but you may have gone down to 8 or even less, find more info.
- I don't have a Cache Lifespan option with my cache plugin: some cache plugins don't have a Cache Lifespan option, in case please contact the author of the plugin for more information. For example, Autoptimize does not have its proper cache purging mechanism, as this could remove optimized CSS/JS which is still referred to in other caches, which would break your site. Moreover, a fast-growing cache is an indication of other problems you should avoid. Despite the above objections, there are 3rd party solutions to automatically purge the AO cache, e.g. using this code or this plugin, but for the reasons above these are to be used only if you really know what you’re doing, find more info.
Cache plugins and WooCommerce
If you are using WP Rocket and WooCommerce, and you are using the 'Recently Viewed Product' widget, please insert this code in the WP Rocket → Advanced Rules → Never Cache Cookies field: