Advanced Caching Options
Advanced settings – exclude URLs
To excude an URL from your cache, add its path to the “List URLs that should not be cached” field. Eg. if you want to exclude http://my-website.com/my-page, insert /my-page
Use of wildcards:
You can use * wildcards to match several pages. For example, /shop/* will exclude all pages with /shop at the beginning of their path. You can also use 2 * to exclude a page containing a string anywhere in its path. Eg. entering *shop* will exclude http://my-website.com/shop as well as http://my-website.com/about-the-shop-and-more
Extending the page cache
Adding custom cache extensions
- First, choose a location to store your code. Set the constant WPO_CACHE_CUSTOM_EXT_DIR in your site’s wp-config.php. For example:
define( 'WPO_CACHE_CUSTOM_EXT_DIR', ABSPATH . '/path/to/cache/extensions' );
- Create a php file in this location, and add your code.
- If you have the premium version, you can look in wp-optimize/cache/extensions for examples.
Overriding existing extensions
If your version of WP-Optimize comes with bundled extensions, you can override them. To do so, you need to copy them somewhere outside of WP-Optimize’s folder, to prevent them from being overridden when updating the plugin:
- Copy the folder wp-optimize/cache/extensions to a custom location
- In your site’s wp-config.php, define the constant WPO_CACHE_EXT_DIR with the folder you chose to copy the default extensions to. For example:
define( 'WPO_CACHE_EXT_DIR', ABSPATH . '/path/to/default/cache/extensions' );
- There you can override the extensions, and your changes will be kept when WP-Optimize will be updated.
- You can also add your own extensions in this folder, without the need to use the extra WPO_CACHE_CUSTOM_EXT_DIR method.
Purging the cache from an other plugin or theme
You can trigger a cache purge using WP-Optimize public functions.
Use WP_Optimize()->get_page_cache()->purge(); to flush the whole cache.
Use WPO_Page_Cache::delete_single_post_cache($post_id); to purge a single post’s files.
Those cache options are available from WordPress action plugins_loaded.