如何以编程方式清空浏览器缓存? [英] How to programmatically empty browser cache?

查看:40
本文介绍了如何以编程方式清空浏览器缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种以编程方式清空浏览器缓存的方法.我这样做是因为应用程序缓存了机密数据,我想在您按注销"时删除这些数据.这将通过服务器或 JavaScript 发生.当然,仍然不鼓励在外国/公共计算机上使用该软件,因为有更多的危险,例如您无法在软件级别上击败的键盘记录器.

I am looking for a way to programmatically empty the browser cache. I am doing this because the application caches confidential data and I'd like to remove those when you press "log out". This would happen either via server or JavaScript. Of course, using the software on foreign/public computer is still discouraged as there are more dangers like key loggers that you just can't defeat on software level.

推荐答案

有可能,您可以简单地使用 jQuery 来替换引用缓存状态的元标记"与事件处理程序/按钮,然后刷新,简单,

It's possible, you can simply use jQuery to substitute the 'meta tag' that references the cache status with an event handler / button, and then refresh, easy,

$('.button').click(function() {
    $.ajax({
        url: "",
        context: document.body,
        success: function(s,x){

            $('html[manifest=saveappoffline.appcache]').attr('content', '');
                $(this).html(s);
        }
    }); 
});

注意:此解决方案依赖于作为 HTML 5 规范的一部分实现的应用程序缓存.它还需要服务器配置来设置应用程序缓存清单.它没有描述一种可以通过客户端或服务器端代码清除传统"浏览器缓存的方法,而这几乎是不可能做到的.

NOTE: This solution relies on the Application Cache that is implemented as part of the HTML 5 spec. It also requires server configuration to set up the App Cache manifest. It does not describe a method by which one can clear the 'traditional' browser cache via client- or server-side code, which is nigh impossible to do.

这篇关于如何以编程方式清空浏览器缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆