禁用 Internet Explorer 8 jQuery 中的缓存问题

Disable caching issue in jQuery for Internet Explorer 8

本文关键字:缓存 问题 jQuery Internet Explorer 禁用      更新时间:2023-09-26

>我无法查看数据库中更新的新搜索结果。仅使用 Internet Explorer 8。我尝试刷新页面,但这没有任何作用。Chrome和Firefox工作正常。

我可以通过选择"检查存储页面的新版本:每次访问网页时"来暂时解决此问题。但是,当我将其转移到生产中时,这意味着它不适用于使用 IE 8 9 或 10 的最终用户。

任何有用的提示,不胜感激。提前谢谢。

这是我已经尝试过的:

<script> type=“text/javascript" src="js/jquery-1.9.1.min.js?new=yes"></script>
$(document).ready(function () {
    //http://stackoverflow.com/questions/217957/how-to-print-debug-messages-in-the-google-chrome-javascript-console/2757552#2757552
    if (!window.console) console = {};
    console.log = console.log || function () {};
    console.dir = console.dir || function () {};
    //listen for keyup on the field
    $("#searchField").keyup(function () {
        //get and trim the value
        var field = $(this).val();
        field = $.trim(field)
        //if blank, nuke results and leave early
        if (field == "") {
            $("#results").html("");
            return;
        }
        console.log("searching for " + field);
        $.getJSON("cfc/test.cfc?returnformat=json&method=search", {
            "search": field
        }, function (res, code) {
            var s = "<table width='1000' class='gridtable' name='table1' border='1'><tr><th width='40'>Attuid</th><th width='80'>Device</th><th width='55'>Region</th><th width='140'>Problem</th><th width='160'>Description</th><th width='120'>Resolution</th> <th width='180'>Resolution Description</th><th width='40'>Agent</th><th width='140'>Timestamp</th></tr>";
            s += "";
            for (var i = 0; i < res.table_demo.length; i++) {
                s += "<tr><td width='42'>" + res.table_demo[i].pa_uid +
                    "</td><td width='80'>" + res.table_demo[i].pa_device +
                    "</td><td width='55'>" + res.table_demo[i].pa_region +
                    "</td><td width='140'> " + res.table_demo[i].pa_problem +
                    "</td><td width='160'> " + res.table_demo[i].pa_description +
                    "</td><td width='120'>" + res.table_demo[i].pa_resolution +
                    "</td><td width='180'>" + res.table_demo[i].pa_rdescription +
                    "</td><td width='42'> " + res.table_demo[i].pa_agent +
                    "</td><td width='140'> TimeStamp"
                "</td>";
                s += "</tr>";
            }
            s += "</table>";
            $("#results").html(s);
        });
    });
})

尝试$.ajaxSetup({ cache: false });禁用 jQuery 缓存。

另外,要立即使页面过期,请尝试添加元标记:

<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="-1" />