How to clear cache without a plugin [closed]

If this is about .css and .js changes, one way is to add “versions” of your files. For example:

script_1.0.css // This is the URL for release 1.0
script_1.1.css // This is the URL for release 1.1
script_1.2.css // etc.

Or alternatively do it after the file name:

script.css?v=1.0 // This is the URL for release 1.0
script.css?v=1.1 // This is the URL for release 1.1
script.css?v=1.2 // etc.

In wordpress you have option for versions of included JS files in wp_enqueue_script() in PHP:

/*EXAMPLE*/
wp_enqueue_script("yourscript", "joursctipt.min.js",array(),'3.3.5',true);

Here is DOCUMENTATION!

Also you can do that in CSS but manualy in URL:

wp_enqueue_style( 'toalc', get_template_directory_uri().'/style.css?v=1.0.5');

When you change something in your CSS or JS, just change version of your file and cache will be deleted.

If is cache of your images then you have one trick:

<img src="https://wordpress.stackexchange.com/questions/205779/image.jpg?v=1">

or using PHP random string for each image to clear cache on each refresh:

<img src="https://wordpress.stackexchange.com/questions/205779/image.jpg?v=<?=mt_rand(1000,9999); ?>">

Text and other forms is not stored in cache, autocomplete forms you can prevent with:

<input autocomplete="off">

NOTE: autocomplete is supported only for few browsers.

Leave a Comment

error code: 523