Skip to content

Instantly share code, notes, and snippets.

@broskees
Last active January 10, 2020 22:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save broskees/1bc379fe0e47dd60a443a514a71b5d7c to your computer and use it in GitHub Desktop.
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.
<?
/**
* 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