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):
Here are some notes for all Uncode and WP Rocket users:
- When using WP Rocket or any other cache plugin, please use the Adaptive Images Async or the Dynamic Srcset Images (new suggested method). These features enable your visitors to load low-resolution versions of your images when they first visit your site and improve loading times.
- If you use the WP Rocket option Minify JavaScript files, you should also enable the Uncode → Theme Options → Performances → Production Mode.
- Please take care using the Load JavaScript deferred and the Delay JavaScript execution options, which can create unexpected results (as alarmed by the plugin itself when you activate the options).
Free alternative cache plugins
All of the commercial or free caching plugins for WordPress are excellent options. It's important you verify that the plugin you use has the ability to exclude JavaScript files from the minify option since Uncode already does so (this is a common option for the best cache plugins).
A good free cache plugin is Breeze. To exclude the required JavaScript files from the minify, go to Settings → Breeze → Advanced Options → Exclude JS and add the following lines to it, screenshot :
/wp-content/themes/uncode/library/js/init.js
/wp-content/themes/uncode/library/js/init.min.js
/wp-content/themes/uncode/library/js/ai-uncode.js
/wp-content/themes/uncode/library/js/ai-uncode.min.js
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:
woocommerce_recently_viewed
Comments
0 comments
Article is closed for comments.