首页 > performance性能统计,部分机型返回页面加载时长很大,怀疑是缓存原因

performance性能统计,部分机型返回页面加载时长很大,怀疑是缓存原因

performance.timing.navigationStart统计页面加载时间

采用performance.timing.navigationStart统计首页加载时长,当接口读取完毕后发送统计信息,代码如下:

function logCostTime(){
    var _performance = window.performance || window.webkitPerformance || window.msPerformance || window.mozPerformance;
    //type:0链接进来;1刷新;2回退按钮;3其他
    if (_performance !== undefined && _performance.navigation.type === 0) {
        var costTime = +new Date() - _performance.timing.navigationStart;
        if(isNumeric(costTime)) {
            $.ajax({
                url: "/error/logloadtime?costTime=" + costTime,
                type: 'get',
                dataType: 'json',
                contentType: "application/json;charset=utf-8",
                cache: false,
                success: function (responseData) {
                }
            });
        }
    }
}
//判断是否有效数字
function isNumeric(n) {
    return !isNaN(parseFloat(n)) && isFinite(n);
}

问题来了,部分机型(目前观察到android4.2,android4.1)有时候会返回特别大的值,大概2到3天,目前原因未定位,怀疑是缓存的原因,有什么解决办法吗?

【热门文章】
【热门文章】