With our newest updates, you can now exclude Shortcodes from the cache. We have a full article on explaining how - How to Use The Shortcodes Exclusions Feature in WordPress.
You can also use several workarounds:
1. Exclude pages from caching
You can exclude the affected pages from being cached as per our guide:
Excluding the pages from optimizations will halt all NitroPack optimizations on them; however, the shortcodes will work as expected, and the information will continuously be up-to-date.
*We recommend this method if there are only a few affected pages.
2. WordPress alternatives
2.1. JavaScript/AJAX compatibility
Check if the plugin you’re using for the shortcode has a JavaScript/AJAX compatibility option and enable it:
If you cannot find such an option, we recommend checking with the plugin’s support team whether they are compatible with caching.
This will resolve the issue and work well with caching solutions such as NitroPack.
2.2. Using Widgets
In case you are using shortcodes in Widgets, you could use a plugin to transform them into AJAX widgets, such as this one:
Important: The above solution for Widgets is only for WordPress websites.
2.3. Automatically purge pages at set intervals
You can purge the cache for pages automatically by using WP-CLI along with a Cron Job.
To achieve this, use our guide:
This way, if the pages’ content gets updated more frequently, you can set a cron job to purge the cache automatically, resulting in updated information on the pages.
📌 If you need any assistance or have questions, reach out to our support team at [email protected] or via this link: https://support.nitropack.io