必须删除Chrome中的缓存,才能查看我在WordPress wesbite上所做的CSS更改。可以自动处理吗?

我做了一个Wordpress主题。但是最近, 我对代码进行了每次更改后, 都必须删除Chrome中的缓存才能看到更改。

可以通过添加到funtions.php的插件或代码行自动处理此问题吗?


#1


是的, 你可以使指向CSS的链接使用带有时间戳的查询字符串。这样, 你将在每次加载时获得唯一的链接。

假设你正在使用wp_enque_style()加载样式, 有一个version参数, 使用time()函数将其设置为当前时间, 它将添加到链接中。

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

有关wp_enqueue_scripts的更多信息

来源:

https://www.srcmini02.com/65634.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_40851.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?