1. Home
  2. Docs
  3. WordPress Tips & Tri...
  4. 브라우저 캐슁에서 자식 테마 스타일은 제외시키기

브라우저 캐슁에서 자식 테마 스타일은 제외시키기

#1. 스타일 파일의 링크 연결 시 랜덤 쿼리문이 포함되도록 하여 브라우저가 스타일을 매번 다시 읽게 하는 방법을 이용

// 스타일을 enqueue 할 때 아래와 같이 적용 
$rand = rand( 1, 99999999999 );
wp_enqueue_style( 'mytheme-child-style', get_stylesheet_directory_uri().'/css/custom.css', '', $rand );

#2. 실제 파일이 변경 시에만 다시 읽게 하는 방법

// no cache style 
wp_enqueue_style( 'style-custom', get_stylesheet_directory_uri().'/style-custom.css', array(), filemtime( dirname( __FILE__ ) . '/style-custom.css' ));