Last active
January 10, 2020 22:35
-
-
Save broskees/1bc379fe0e47dd60a443a514a71b5d7c to your computer and use it in GitHub Desktop.
A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* Plugin Name: WordPress Catch All Cache Buster | |
* Description: A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option. | |
* Version: 1.0.0 | |
* Author: Joseph Roberts | |
* Author URI: https://github.com/DigitalJoeCo | |
* License: MIT | |
* License URI: http://opensource.org/licenses/MIT | |
*/ | |
defined( 'ABSPATH' ) or exit; // Exit if accessed directly. | |
add_action('template_redirect', function() { | |
if(!isset($_COOKIE['nocache']) and !$_GET['nocache']){ | |
$location = esc_url(add_query_arg('nocache', (string) rand(00000, 99999))); | |
wp_redirect($location); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment