Plugin / Clear Cache for Me
Webhead LLCDescription
Description
W3 Total Cache and WP Super Cache are great caching plugins, but they do not know when a widget is updated. WPEngine is the best place to host your WordPress installation, but their caching system is no smarter when it comes to updating widgets and menus. I created this plugin because my website did not see any changes when saving widgets or menus using these caching systems. Clear Cache For Me will purge ALL your cache each time you do a save without having to press an additional button. It may be overkill, which may be why it’s not built in, but some people need simplicity.
In addition to clearing those pesky caching engines, Clear Cache for Me can force your browser to reload your current theme’s CSS and JS files. I modify my theme’s CSS and JS files every so often and always have trouble with the browser not getting the latest version. So now after clicking on the “Clear Cache Now!” button on the dashboard the browser will be forced to reload the current theme’s CSS and JS files. If you do not click the “Clear Cache Now!” button, the browser will cache the CSS and JS files like it normally does.
The popular Qode themes has a options to set your own custom CSS and JS. Sometimes you may not see your changes for a long while because your browser is trying to get the cached file. Whenever you save your Qode’s options, the CSS and JS files will be forced to reload in the browser on the public side.
Works with the following caching systems:
- W3 Total Cache
- WP Super Cache
- WP Fastest Cache
- WPEngine hosting
Clears all cache for following actions:
- When Widgets are saved
- When Customizer is saved
- When Menus are saved
- When Settings from a settings page is saved.
- When a Contact Form 7 form is saved.
- When WooThemes settings are saved.
- When NextGen Gallery albums and galleries are updated (beta – may not clear cache on all actions).
- When Qode options are saved this plugin forces browsers to reload the custom css and custom js.
There is a convenient clear cache button on the dashboard for users with the right capability. Admins (users with the ‘manage_options’ capability) can set which capability a user needs to view the button. If you are using this button often, please consider submitting a request to have this plugin do your button-pushing for you. This plugin is meant to work behind the scenes to make your life easier and less frustrating.
Developer Options
ccfm_supported_caching_exists
Use this filter to determine if this plugin should do anything including showing the button on the dashboard. Return true if a caching system is supported.
Default: True if any of the supported caching systems is active.
See Example 1 below.
ccfm_admin_init
Use this action to add hooks when cache is to be cleared. Or do any other setup activity.
ccfm_clear_cache_for_me_before
Use this action to clear cache from an unsupported caching system before the default caching systems clear their cache.
ccfm_clear_cache_for_me
Use this action to clear cache from an unsupported caching system after the default caching systems clear their cache.
Example 1
Thanks to Benjamin Pick – If you are using Autoptimize and need to clear the CSS or JS files automatically, you can add the code below to your theme’s functions.php file. This code also demonstrates how you can add an unsupported caching system and have its cache cleared for you.
https://gist.github.com/benjaminpick/94b487ce995454797143
also pasted below:
<?php
function yt_cache_enable($return) {
if (class_exists(‘autoptimizeCache’))
return true;
return $return;
}
add_filter('ccfm_supported_caching_exists', 'yt_cache_enable');
function yt_cache_clear() {
if (class_exists('autoptimizeCache'))
autoptimizeCache::clearall();
}
add_action('ccfm_clear_cache_for_me', 'yt_cache_clear');
Example 2
Thanks to Benjamin Pick – If you have an automatic deployment setup and need a webhook to clear the caches, you can add this code to your theme’s functions.php file.
https://gist.github.com/benjaminpick/67b6b9a49ef7991172f9
also pasted below:
<?php
if (!defined(‘CLEAR_CACHE_HOOK_KEY’))
define(‘CLEAR_CACHE_HOOK_KEY’, ‘some_secret_key_please’);
function yt_cache_clear_web_hook() {
if (isset($_GET['key']) && $_GET['key'] == CLEAR_CACHE_HOOK_KEY) {
if (function_exists('ccfm_clear_cache_for_me')) {
ccfm_clear_cache_for_me( 'ajax' );
echo 'Cache was cleared.';
} else {
echo 'Install the plugin "Clear Cache For Me" first';
}
exit;
}
}
// Call this URL to clear the cache:
// /wp-admin/admin-ajax.php?action=clear_cache&key=some_secret_key_please
add_action( 'wp_ajax_clear_cache', 'yt_cache_clear_web_hook' );
add_action( 'wp_ajax_nopriv_clear_cache', 'yt_cache_clear_web_hook' );
Ratings
Rating breakdown
Details Information
DIRECTORY DISCLAIMER
The information provided in this THEME/PLUGIN DIRECTORY is made available for information purposes only, and intended to serve as a resource to enable visitors to select a relevant theme or plugin. wpSocket gives no warranty of any kind, express or implied with regard to the information, including without limitation any warranty that the particular theme or plugin that you select is qualified on your situation.
The information in the individual theme or plugin displayed in the Directory is provided by the owners and contributors themselves. wpSocket gives no warranty as to the accuracy of the information and will not be liable to you for any loss or damage suffered by you as a consequence of your reliance on the information.
Links to respective sites are offered to assist in accessing additional information. The links may be outdated or broken. Connect to outside sites at your own risk. The Theme/Plugin Directory does not endorse the content or accuracy of any listing or external website.
While information is made available, no guarantee is given that the details provided are correct, complete or up-to-date.
wpSocket is not related to the theme or plugin, and also not responsible and expressly disclaims all liability for, damages of any kind, arising out of the use, reference to, or reliance on, any information or business listed throughout our site.