当我使用谷歌浏览器访问我的网站时,Chrome会显示(使用#34; Cookie和网站数据")它使用的是LocalStorage和IndexedDB。我不刻意这样做,我想知道为什么这些出现在列表中。
该网站确实使用了一些第三方内容,特别是(可能)Google Universal Analytics和Google跟踪代码管理器,但我检查了这些内容的JS源代码(包括即时下载的文件),并且可以找不到对LocalStorage或IndexedDB的明显引用(虽然它不容易阅读缩小的代码)。
有没有办法告诉使用这些功能的是什么?
FWIW它是一个ASP.NET MVC5网站,但我怀疑它是否相关。
1 个答案:
答案 0 :(得分:1)
If you don't have specific code doing this, then third party analytics/ads are the likely culprit. Here's what I'd try:
Use chrome://settings/cookies and delete the storage for your site
Identify a page in your site that causes the data to be written
Modify the page to have an inline script before any other scripts are loaded, that shims the storage APIs with dummy functions like:
window.indexedDB.open = function() {
throw Error('Indexed DB');
};
window.localStorage.setItem = function() {
throw Error('DOM Storage');
};
Reload the page with the developer console open. If you're lucky you'll see exceptions thrown with a stack trace pointing to the code that tried to use those functions.
If not, change those throw lines to simply debugger; to invoke the debugger, and reload the page again. The call stack in the debugger should show you what library is using the storage APIs.