0

I've made an Wordpress theme. But recently, after every change I make in the code, the cache in Chrome has to be deleted to see the change.

Can this be handled automatic with a plugin or a line of code to add to the funtions.php?

Gíp
  • 3
  • 6

1 Answers1

0

Yes, you can make the link to the css use a query string with a timestamp. This way you will get a unique link each load.

Assuming you are using wp_enque_style() to load the style, there is a version parameter, set this to the current time with the function time() and it will add it to the link.

function themeslug_enqueue_style() {
    wp_enqueue_style( 'mystyle', 'path/to/mystyle.css', false, time() ); 
}
add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );

More info about wp_enqueue_scripts

Fokusiv
  • 53
  • 4
  • 1
    You would have to remember not to put this into production otherwise you will cause everyone to redownload files all the time -not great for page load times – Pete Feb 07 '18 at 12:50