How can I render shortcode so that its not cached by Caching plugins?

I am developing a plugin and I don’t want the output of my shortcode to be cached by popular WordPress caching plugins like W3Ttoalcahe, WPSuperCache, etc. Is there any way I can achieve that or ask my users to configure their caching plugins so that my shortcodes are rendered dynamically and its output is not cached?

1 Answer
1

I don’t think that there is a way to do this. All that shortcode does is generating some HTML code and putting it as content.

But… there is a workaround you can use. Your shortcode can generate only a placeholder for its content and then you can use AJAX to populate it with real content. It’s a pretty common practice to deal with cache in WP – for example WooCommerce uses exactly this method for its cart.

PS. If you’re using W3TC you can set a list of pages that shouldn’t be served from cache.

Leave a Comment