Title: clear the cache programmatically
Last modified: January 9, 2021

---

# clear the cache programmatically

 *  Resolved [foxpc](https://wordpress.org/support/users/foxpc/)
 * (@foxpc)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/clear-the-cache-programmatically/)
 * Hi,
    how to clear the cache programmatically from code? i want to emulate the
   bar button that Clear the cached assets/js.
 * Thanks!

Viewing 1 replies (of 1 total)

 *  Plugin Author [Gabe Livan](https://wordpress.org/support/users/gabelivan/)
 * (@gabelivan)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/clear-the-cache-programmatically/#post-13895501)
 * [@foxpc](https://wordpress.org/support/users/foxpc/) you can use the following
   snippet to clear Asset CleanUp’s caching outside the plugin (e.g. if you’re using
   another plugin and you want to clear Asset CleanUp’s caching after a certain 
   action from the other plugin is taken):
 * `add_action('init', function() {
    if (method_exists('\WpAssetCleanUp\OptimiseAssets\
   OptimizeCommon', 'clearCache')) { \WpAssetCleanUp\OptimiseAssets\OptimizeCommon::
   clearCache(); } }, PHP_INT_MAX);
 * I hope it helps! Let me know if I can further assist you!

Viewing 1 replies (of 1 total)

The topic ‘clear the cache programmatically’ is closed to new replies.

 * ![](https://ps.w.org/wp-asset-clean-up/assets/icon-256x256.png?rev=1981952)
 * [Asset CleanUp: Page Speed Booster](https://wordpress.org/plugins/wp-asset-clean-up/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-asset-clean-up/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-asset-clean-up/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-asset-clean-up/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-asset-clean-up/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-asset-clean-up/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Gabe Livan](https://wordpress.org/support/users/gabelivan/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/clear-the-cache-programmatically/#post-13895501)
 * Status: resolved