当新网站上线时,用户报告看到旧网站

时间:2019-02-15 09:23:42

标签: wordpress caching browser-cache cache-control

我最近发布了一种新样式:summerboardingcourses.co.uk

我收到一个用户的报告,说他们正在波兰(我位于英国)的iPhone Safari浏览器上看到旧网站(样式损坏)。我无法复制该问题,我使用的每个VPN或我使用的GeoLocation屏幕截图工具(例如localbrowser.com)都可以正确查看该站点。

以前有没有人遇到过这样的问题?我不明白他们为什么会看到旧网站。

任何建议都是很棒的。

谢谢, 梅格

1 个答案:

答案 0 :(得分:0)

/* Return Last modified date or current date*/
function get_mod_time($file) {
    if (file_exists($file)) {
        return date("y.m.d-H", filemtime($file));
    }
    else {
        return date('y.m.d-H');
    }
}

/* Include style */
$css_file = get_template_directory_uri() . '/assets/css/style.css';
wp_enqueue_style( 'site-css', $css_file, array(), get_mod_time($css_file), 'all' );

同样认为您可以为您的自定义JS文件做准备,您将最后修改日期作为版本名,如果服务器上的文件已更新,则强制清除缓存

相关问题