我尝试将此代码用于清除缓存,但它无法与Google Chrome一起使用。 我需要清除浏览器中的所有缓存或清除所有网站缓存(不仅仅是一页) Ps:大多数代码使用小部件DOJO javascript,为什么我需要清除所有缓存。
List<string> keys = new List<string>();
// retrieve application Cache enumerator
IDictionaryEnumerator enumerator = Cache.GetEnumerator();
// copy all keys that currently exist in Cache
while (enumerator.MoveNext())
{
keys.Add(enumerator.Key.ToString());
}
// delete every key from cache
for (int i = 0; i < keys.Count; i++)
{
Cache.Remove(keys[i]);
}
HttpRuntime.Close();
感谢您的每一个答案。
答案 0 :(得分:0)
您可以尝试这样清除浏览器的所有缓存
/**
* Inserts the key-value pair into the symbol table, overwriting the old value
* with the new value if the key is already in the symbol table.
* If the value is <tt>null</tt>, this effectively deletes the key from the symbol table.
*
* @param key the key
* @param val the value
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>
*/
public void put(Key key, Value val) {
if (val == null) {
delete(key);
return;
}
root = put(root, key, val);
assert check();
}
private Node put(Node x, Key key, Value val) {
if (x == null) return new Node(key, val, 1);
int cmp = key.compareTo(x.key);
if (cmp < 0) x.left = put(x.left, key, val);
else if (cmp > 0) x.right = put(x.right, key, val);
else x.val = val;
x.N = 1 + size(x.left) + size(x.right);
return x;
}
您还可以参考:Making sure a web page is not cached, across all browsers