WP Rocket is a popular caching plugin for WordPress that helps improve website performance by storing static files and serving them directly from the server. However, there may be instances where you need to disable cache in WP Rocket for certain pages or posts.
Why Disable Cache in WP Rocket?
There are several reasons why you might want to disable cache in WP Rocket. For example, if you’re making changes to a page or post and need to see the updates immediately, disabling cache can help prevent any delays caused by cached files.
How to Disable Cache for Specific Pages or Posts
To disable cache for specific pages or posts in WP Rocket, you’ll need to add a custom code snippet to the page or post. Here are the steps to do so:
- Open the page or post you want to disable cache for in your WordPress dashboard.
- Click on the “Text” tab in the editor toolbar.
- Add the following code snippet to the top of the page or post:
- Save your changes and publish the page or post.
add_filter( 'rocket_cache_reject_uri', '__return_true' );
How to Disable Cache for All Pages or Posts
If you want to disable cache for all pages or posts on your website, you can do so by adding a custom code snippet to your theme’s functions.php file. Here are the steps to do so:
- Open your theme’s functions.php file in a text editor.
- Add the following code snippet to the top of the file:
- Save your changes and upload the updated functions.php file to your server.
add_filter( 'rocket_cache_reject_uri', '__return_true' );
Conclusion
Disabling cache in WP Rocket can be a useful tool for troubleshooting issues or making quick updates to your website. By following these steps, you can easily disable cache for specific pages or posts or for all pages on your site.