To make features like social media feeds, navigation menus, or dynamic ads work smoothly when cached, exclude the shortcodes from NitroPack’s cache.
Excluding a shortcode from the cache means NitroPack won’t cache this specific element of the page but instead load it dynamically (via AJAX) on every page load. This way, the content gets loaded fresh every time.
Furthermore, the “Shortcodes exclusions” feature removes the need to use a third-party plugin like No Cache AJAX Widgets – WordPress plugin.
How to Exclude a Shortcode from NitroPack Caching
Disclaimer: Excluding too many shortcodes can slow down the site. Only exclude shortcodes that need real-time updates or aren’t displaying correctly with caching.
1. Log in to the WordPress admin area
2. On the left sidebar, find NitroPack and click on it
3. In the NitroPack settings, go to Exclusions >> Shortcodes exclusions
4. After enabling the feature, in the field, type in the shortcode you want NitroPack to ignore (e.g., `[social_feed],` `[ads_rotator],` etc.).
Important: We detect and prefill most shortcodes a website uses. However, you can still manually add another shortcode. Add it using only the shortcode name—no brackets or extra symbols. Furthermore, shortcode attributes do not need to be added. Once a shortcode is added, you are ready to go.
5. Scroll down and click Save.
Important: Simply enabling the feature will have zero impact on your site’s performance. You must add a shortcode in the field for NitroPack to optimize it.
Once saved, NitroPack will bypass the cache for these shortcodes.
How Check If a Shortcode is Excluded From Optimizations
After excluding the shortcode(s), do a quick check to confirm everything’s working:
1. Open the page where the shortcode is used and refresh it.
2. Check if the excluded element (like the ad or social feed) updates as expected.
To perform a manual check, follow these steps:
1. Open a page as a non-logged user with already added shortcodes (make sure to clear/invalidate the page cache before that).
2. Open the browser’s “Network” tab, and look for admin-ajax.php request with a name “nitro_shortcode_ajax”
In ~/wp-content/plugins/nitropack/classes\Feature\AjaxShortcodes.php - you can find the whole logic.
You can also add shortcodes in wp-config.php as a constant NITROPACK_AJAX_SHORTCODES.
3. Finally, the added shortcodes are stored in NitroPack >> config.json, not in the WordPress database! This means that you can even add them inside the options_cache object.
Example:
"options_cache": {
"ajaxShortcodes": {
"enabled": true,
"shortcodes": [
"products",
"test"
]
},
},
📌 If you need any assistance or have questions, you can contact our Support team using the chat bubble on the bottom right of this page.