# Clear WP Rocket When Site Settings Change

> Clears WP Rocket's whole-site cache when you save the Customizer, change menus or edit widgets, so header, footer and sidebar changes show up immediately.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: wp-rocket, cache, customizer
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/rocket-purge-after-options-save/

## Code

```php
$wpide_clear = function () {
    if ( function_exists( 'rocket_clean_domain' ) ) {
        rocket_clean_domain();
    }
};

add_action( 'customize_save_after', $wpide_clear );
add_action( 'wp_update_nav_menu', $wpide_clear );
add_action( 'update_option_sidebars_widgets', $wpide_clear );
```

## Notes

WP Rocket already clears for theme switches; this covers the everyday design edits.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Clear WP Rocket When Site Settings Change" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
